October 2017
Intermediate to advanced
280 pages
6h 50m
English
Now, let's take a look at an example similar to the one used earlier, but with a syntactically different configuration of the injector:
@NgModule({ // ... providers: [
{ provide: BUFFER_SIZE, useValue: 42 },
{ provide: Buffer, useClass: Buffer },
{ provide: Socket, useClass: Socket }
] // ...})class AppModule {}
In this case, inside the provider, we explicitly declared that we want the Buffer class to be used for the construction of the dependency with a token equal to the reference of the Buffer identifier. We do the exact same thing for the dependency associated with the Socket token; however, this time, we provided the Socket class instead. This is how Angular will proceed when we omit the explicit provider declaration ...
Read now
Unlock full access