當我使用以下JIT指令編譯時ng build
; ng build --prod
一切都還好,當我建立AOT使用--aot
國旗,ng build --aot
該應用程序的作品。 但是當我嘗試使用ngc
我收到以下錯誤編譯(AOT):AOT-ngc無法解析組件的所有參數
Can't resolve all parameters for HomeComponent in /appname/src/app/home/home.component.ts: (?).
這是HomeComponent類:
import {EventManager} from 'app/directives/EventManager.directive';
@Component({
selector:'home',
template:`
...
`,
styleUrls: ['./home.component.css']
})
export class HomeComponent {
showLoggedBar:Boolean;
constructor(private _eventManager:EventManager) {
this._eventManager.showLoggedBar.subscribe((mode)=> {
if(mode)
{
this._eventManager.showBar.emit(true);
this.showLoggedBar = mode;
}
});
}
}
將帖子eventmanager進行:
@Injectable()
export class EventManager {
public showLoggedBar: EventEmitter<any> = new EventEmitter();
public showLoggedDoBar: EventEmitter<any> = new EventEmitter();
public showDoBar: EventEmitter<any> = new EventEmitter();
public showBar:EventEmitter<any>=new EventEmitter();
public dataSearch:EventEmitter<any>= new EventEmitter();
public updateP:EventEmitter<any>=new EventEmitter();
public updateD:EventEmitter<any>=new EventEmitter();
public detailsAvailable:EventEmitter<any>= new EventEmitter();
public infoAp:EventEmitter<any>= new EventEmitter();
constructor() {
this.showBar.emit(true);
}
}
[EDITED] app.module.ts:
import{NgModule} from '@angular/core';
import {
LocationStrategy,
PathLocationStrategy
} from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { routing, appRoutingProviders } from './app.routing';
import { HomeComponent } from './home/home.component';
import { HttpModule } from '@angular/http';
import {EventManager} from '../app/directives/EventManager.directive';
@NgModule({
declarations:
[
...
HomeComponent,
...
],
imports: [BrowserModule,HttpModule,...],
bootstrap: [AppComponent],
providers:[
...
EventManager,
...
]
})
export class AppModule {}
您是否有任何關於錯誤原因的想法?
你在哪裏導入/提供'eventManager'? – echonax
我想這個問題應該是它提供的地方。 –
@GünterZöchbauer「你提供的地方」是什麼意思?我用EventManager指令更新了我的問題 – Franky