dependency injection - Angular 2 AOT - Property 'window' does not exist on type -
in angular 2 application provide window object using described here: angular2 - how inject window angular2 service.
however ngc compiler used aot returns several errors. first had change way provide dependency (note 'window'):
@ngmodule({ providers: [ { provide: 'window', usevalue: window } ], ... }) export class appmodule {}
and in component (note type 'any'):
@component({ ... }) export default class mycomponent { constructor ( @inject('window') private window: ) {} ...
however still following error thrown ngc compiler in module ngfactory:
property 'window' not exist on type
again working fine tsc compiler.
in end fixed issue following described here: http://juristr.com/blog/2016/09/ng2-get-window-ref/
Comments
Post a Comment