This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const providerDef = | |
(allowPrivateServices ? elDef.element!.allProviders : | |
elDef.element!.publicProviders)![tokenKey]; | |
if (providerDef) { | |
let providerData = asProviderData(searchView, providerDef.nodeIndex); | |
if (!providerData) { | |
providerData = { instance: _createProviderInstance(searchView, providerDef) }; | |
searchView.nodes[providerDef.nodeIndex] = providerData as any; | |
} | |
return providerData.instance; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface ElementDef { | |
... | |
/** | |
* visible public providers for DI in the view, | |
* as see from this element. This does not include private providers. | |
*/ | |
publicProviders: {[tokenKey: string]: NodeDef}|null; | |
/** | |
* same as visiblePublicProviders, but also includes private providers | |
* that are located on this element. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Injector_ implements Injector { | |
constructor(private view: ViewData, private elDef: NodeDef|null) {} | |
get(token: any, notFoundValue: any = Injector.THROW_IF_NOT_FOUND): any { | |
const allowPrivateServices = | |
this.elDef ? (this.elDef.flags & NodeFlags.ComponentView) !== 0 : false; | |
return Services.resolveDep( | |
this.view, this.elDef, allowPrivateServices, | |
{flags: DepFlags.None, token, tokenKey: tokenKey(token)}, notFoundValue); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: '[someDir]' | |
} | |
export class SomeDirective { | |
constructor(private injector: Injector) {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
platformBrowserDynamic().bootstrapModule(AppModule); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'my-app', | |
template: `<child></child>`, | |
}) | |
export class AppComponent {} | |
@Component({ | |
selector: 'child', | |
template: `<grand-child></grand-child>` | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createRootData( | |
elInjector: Injector, ngModule: NgModuleRef<any>, rendererFactory: RendererFactory2, | |
projectableNodes: any[][], rootSelectorOrNode: any): RootData { | |
const sanitizer = ngModule.injector.get(Sanitizer); | |
const errorHandler = ngModule.injector.get(ErrorHandler); | |
const renderer = rendererFactory.createRenderer(null, null); | |
return { | |
ngModule, | |
injector: elInjector, projectableNodes, | |
selectorOrNode: rootSelectorOrNode, sanitizer, rendererFactory, renderer, errorHandler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ng.probe(getAllAngularRootElements()[0]).injector.view.root.ngModule._parent.parent._records; | |
// to see stringified value use | |
ng.probe(getAllAngularRootElements()[0]).injector.view.root.ngModule._parent.parent.toString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const platform = platformBrowserDynamic([ { | |
provide: SharedService, | |
deps:[] | |
}]); | |
platform.bootstrapModule(AppModule); | |
platform.bootstrapModule(AppModule2); |