當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。