当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript EventManager.subscribe方法代码示例

本文整理汇总了TypeScript中ng-jhipster.EventManager.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EventManager.subscribe方法的具体用法?TypeScript EventManager.subscribe怎么用?TypeScript EventManager.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ng-jhipster.EventManager的用法示例。


在下文中一共展示了EventManager.subscribe方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: registerAuthenticationSuccess

 registerAuthenticationSuccess() {
     this.eventManager.subscribe('authenticationSuccess', (message) => {
         this.principal.identity().then((account) => {
             this.account = account;
         });
     });
 }
开发者ID:lrkwz,项目名称:generator-jhipster,代码行数:7,代码来源:_home.component.ts

示例2: constructor

    constructor(private alertService: AlertService, private eventManager: EventManager, private translateService: TranslateService) {
        this.alerts = [];

        this.cleanHttpErrorListener = eventManager.subscribe('baeldungApp.httpError', (response) => {
            let i;
            let httpResponse = response.content;
            switch (httpResponse.status) {
                // connection refused, server not reachable
                case 0:
                    this.addErrorAlert('Server not reachable', 'error.server.not.reachable');
                    break;

                case 400:
                    let arr = Array.from(httpResponse.headers._headers);
                    let headers = [];
                    for (i = 0; i < arr.length; i++) {
                        if (arr[i][0].endsWith('app-error') || arr[i][0].endsWith('app-params')) {
                            headers.push(arr[i][0]);
                        }
                    }
                    headers.sort();
                    let errorHeader = httpResponse.headers.get(headers[0]);
                    let entityKey = httpResponse.headers.get(headers[1]);
                    if (errorHeader) {
                        let entityName = translateService.instant('global.menu.entities.' + entityKey);
                        this.addErrorAlert(errorHeader, errorHeader, {entityName: entityName});
                    } else if (httpResponse.text() !== '' && httpResponse.json() && httpResponse.json().fieldErrors) {
                        let fieldErrors = httpResponse.json().fieldErrors;
                        for (i = 0; i < fieldErrors.length; i++) {
                            let fieldError = fieldErrors[i];
                            // convert 'something[14].other[4].id' to 'something[].other[].id' so translations can be written to it
                            let convertedField = fieldError.field.replace(/\[\d*\]/g, '[]');
                            let fieldName = translateService.instant('baeldungApp.' +
                                fieldError.objectName + '.' + convertedField);
                            this.addErrorAlert(
                                'Field ' + fieldName + ' cannot be empty', 'error.' + fieldError.message, {fieldName: fieldName});
                        }
                    } else if (httpResponse.text() !== '' && httpResponse.json() && httpResponse.json().message) {
                        this.addErrorAlert(httpResponse.json().message, httpResponse.json().message, httpResponse.json());
                    } else {
                        this.addErrorAlert(httpResponse.text());
                    }
                    break;

                case 404:
                    this.addErrorAlert('Not found', 'error.url.not.found');
                    break;

                default:
                    if (httpResponse.text() !== '' && httpResponse.json() && httpResponse.json().message) {
                        this.addErrorAlert(httpResponse.json().message);
                    } else {
                        this.addErrorAlert(JSON.stringify(httpResponse)); // Fixme find a way to parse httpResponse
                    }
            }
        });
    }
开发者ID:Anuj28282828,项目名称:tutorials,代码行数:57,代码来源:alert-error.component.ts

示例3: registerChangeInComments

 registerChangeInComments() {
     this.eventSubscriber = this.eventManager.subscribe('commentListModification', (response) => this.reset());
 }
开发者ID:Anuj28282828,项目名称:tutorials,代码行数:3,代码来源:comment.component.ts

示例4: registerChangeInProductReviews

 registerChangeInProductReviews() {
     this.eventSubscriber = this.eventManager.subscribe('productReviewListModification', (response) => this.load(this.productReview.id));
 }
开发者ID:chenshao0594,项目名称:eshop,代码行数:3,代码来源:product-review-detail.component.ts

示例5: registerChangeInContentDescriptions

 registerChangeInContentDescriptions() {
     this.eventSubscriber = this.eventManager.subscribe('contentDescriptionListModification', (response) => this.load(this.contentDescription.id));
 }
开发者ID:chenshao0594,项目名称:eshop,代码行数:3,代码来源:content-description-detail.component.ts

示例6: registerChangeInUsers

 registerChangeInUsers() {
     this.eventManager.subscribe('userListModification', (response) => this.loadAll());
 }
开发者ID:JimSpriggs,项目名称:sourdough,代码行数:3,代码来源:user-management.component.ts

示例7: registerChangeInFileHistories

 registerChangeInFileHistories() {
     this.eventSubscriber = this.eventManager.subscribe('fileHistoryListModification', (response) => this.loadAll());
 }
开发者ID:chenshao0594,项目名称:eshop,代码行数:3,代码来源:file-history.component.ts

示例8: registerChangeInWishes

 registerChangeInWishes() {
     this.eventSubscriber = this.eventManager.subscribe('wishListModification', response => this.load(this.wish.id));
 }
开发者ID:JayRaparla,项目名称:jhipster,代码行数:3,代码来源:wish-detail.component.ts

示例9: registerChangeInTransactions

 registerChangeInTransactions() {
     this.eventSubscriber = this.eventManager.subscribe('transactionListModification', (response) => this.loadAll());
 }
开发者ID:JayRaparla,项目名称:jhipster,代码行数:3,代码来源:transaction.component.ts

示例10: registerChangeInZones

 registerChangeInZones() {
     this.eventSubscriber = this.eventManager.subscribe('zoneListModification', (response) => this.load(this.zone.id));
 }
开发者ID:chenshao0594,项目名称:eshop,代码行数:3,代码来源:zone-detail.component.ts


注:本文中的ng-jhipster.EventManager.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。