October 2017
Intermediate to advanced
280 pages
6h 50m
English
There are cases when in an hierarchy, we have defined providers for the same token in different injectors. For instance, let's suppose that we have the preceding example, but with the following injector configuration:
@Component({ selector: 'markdown-panel', viewProviders: [{ provide: Markdown, useValue: null }], // ...})class MarkdownPanel { constructor(private el: ElementRef, private md: Markdown) { } // ...}@Component({ selector: 'app', providers: [Markdown], // ...})class App { constructor() { }}
In the preceding example, in case we try to inject the Markdown service in the constructor of MarkdownPanel, we'll get null, because that's the value associated with the Markdown token in the viewProviders declaration ...
Read now
Unlock full access