October 2017
Intermediate to advanced
280 pages
6h 50m
English
In order to gain a better understanding of the paragraph, let's take a look at this simple example:
// ch6/manual-injector/simple-example.tsclass Http { }class UserService { constructor(public http: Http) { }}const parentInjector = Injector.create([{ provide: Http, deps: [], useFactory() { return new Http(); }}]);const childInjector = Injector.create([{ provide: UserService, deps: [Http], useFactory(http) { return new UserService(http); }}], parentInjector);console.log(childInjector.get(UserService));console.log(childInjector.get(Http) === parentInjector.get(Http));
The imports are omitted since they are not essential to explaining the code. We have two services, Http and UserService, where UserService depends ...
Read now
Unlock full access