dependency injection - How to resolve and create Generic Classes in AngularJS Injector -
have class below,
export class siteeventservicetype<t> { }
how need create instance above class using angularjs 2 injector.
tried not working:
injector.resolveandcreate([siteeventservicetype<string>]).get(siteeventservicetype<string>);
this example posted quite while @ https://github.com/angular/angular/pull/1779
@component( selector: 'my-component', // providers: injectables: const [ const binding( const typeliteral<stream<string>>, tofactory: mycomponent.streamfactory) ] ) @view( directives: const [mychildcomponent], template: '<my-child-component></my-child-component>' ) class mycomponent { static stream<string> streamfactory() => new stream.fromiterable(['hello']); } @component( selector: 'my-child-component' ) @view( template: '{{lastvalue}}' ) class mychildcomponent { string lastvalue; mychildcomponent(stream<string> stringstream) { stringstream.listen((value) => lastvalue = value); } }
see
- https://github.com/angular/angular/issues/1691 c
- and still open issue https://github.com/angular/angular/issues/5704
Comments
Post a Comment