上不存在在我的Angular 2應用程序中,我使用這裏描述的內容提供窗口對象:Angular2 - How to inject window into an angular2 service。Angular 2 AOT - 屬性「窗口」在類型
但是,用於AOT的ngc編譯器會返回多個錯誤。首先,我不得不改變我提供的依賴(注意「窗口」)的方式:
@NgModule({
providers: [
{ provide: 'Window', useValue: window }
],
...
})
export class AppModule {}
而且在我的組件(注意類型「任意」):
@Component({ ... })
export default class MyComponent {
constructor (
@Inject('Window') private window: any
) {}
...
但是我仍然得到由NGC編譯器在我的模塊ngfactory拋出以下錯誤:
屬性「窗口」上不存在類型
再次,一切工作正常與tsc編譯器。