2016-11-17 3 views
0

私は、次のコマンドを使用して、私の角度2プロジェクト実行したときに、私は、エラーを抱えているに-aotコマンドを果たす:エラー走行ngの角度2プロジェクト

ng serve -aot 

スタックトレース:

ERROR in ./src/app/app.module.ngfactory.ts 
Module build failed: Error: /Users/iguissouma/IdeaProjects/myproject/frontend/src/app/shared/services/message.service.ts (9,5): Public property 'messageSource$' of exported class has or is using name 'Observable' from external module "/Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/rxjs/Observable" but cannot be named.) 
    at _transpile (/Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/@ngtools/webpack/src/loader.js:101:19) 
    at /Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/@ngtools/webpack/src/loader.js:128:26 
    at tryCatch (/Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/es6-promise/dist/lib/es6-promise/-internal.js:195:12) 
    at invokeCallback (/Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/es6-promise/dist/lib/es6-promise/-internal.js:210:13) 
    at publish (/Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/es6-promise/dist/lib/es6-promise/-internal.js:178:7) 
    at flush (/Users/iguissouma/IdeaProjects/myproject/frontend/node_modules/es6-promise/dist/lib/es6-promise/asap.js:94:5) 
    at nextTickCallbackWith0Args (node.js:420:9) 
    at process._tickCallback (node.js:349:13) 
@ ./src/main.ts 4:0-64 
@ multi main 

アプリは正常に動作しますng serve

問題を解決するにはどうすればよいですか?

message.service.ts

import { Injectable } from '@angular/core' 
import { Subject } from 'rxjs/Subject'; 
import { Message } from 'primeng/primeng'; 

@Injectable() 
export class MessageService { 
    messageSource = new Subject<Message>(); 

    messageSource$ = this.messageSource.asObservable(); 

    info(summary : string, detail : string) { 
     this.messageSource.next({severity:'info', summary: summary, detail: detail}); 
     console.log("INFO: " + summary + " DETAIL: " + detail); 
    } 

    error(summary : string, detail : string) { 
     this.messageSource.next({severity:'error', summary: summary, detail: detail}); 
     console.log("ERROR: " + summary + " DETAIL: " + detail); 
    } 
} 

答えて

0

私はフィールドの明示的な型を宣言するために、次のようなmessage.service.tsを変更:

import { Injectable } from '@angular/core' 
import { Subject } from 'rxjs/Subject'; 
import { Message } from 'primeng/primeng'; 
import { Observable } from 'rxjs/Rx'; 

@Injectable() 
export class MessageService { 
    messageSource:Subject<Message> = new Subject<Message>(); 

    messageSource$:Observable<Message> = this.messageSource.asObservable(); 

    info(summary : string, detail : string) { 
     this.messageSource.next({severity:'info', summary: summary, detail: detail}); 
     console.log("INFO: " + summary + " DETAIL: " + detail); 
    } 

    error(summary : string, detail : string) { 
     this.messageSource.next({severity:'error', summary: summary, detail: detail}); 
     console.log("ERROR: " + summary + " DETAIL: " + detail); 
    } 
}