angularjs - Angular 2 - injecting service into a component that the service created -
i have service, this:
constructor(private containerref: viewcontainerref, private resolver: componentresolver) {} create(options: any) { this.resolver.resolvecomponent(testcomponent) .then((factory: componentfactory<testcomponent>) => { let ref = this.containerref.createcomponent(factory); }); }
this creates testcomponent
, good. problem comes, when try inject same service component.
constructor(private service: randomservice) { ... }
and here exception: error: uncaught (in promise): typeerror: cannot read property 'query' of null
.
i can inject other service component, not 1 created it. there way it?
Comments
Post a Comment