This file contains 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); |
This file contains 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 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 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 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 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 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 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 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
/** | |
* for component views, this is the host element. | |
* for embedded views, this is the index of the parent node | |
* that contains the view container. | |
*/ | |
export function viewParentEl(view: ViewData): NodeDef|null { | |
const parentView = view.parent; | |
if (parentView) { | |
return view.parentNodeDef !.parent; | |
} else { |
This file contains 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: `<my-list></my-list>` | |
}) | |
export class AppComponent {} | |
@Component({ | |
selector: 'my-list', | |
template: ` | |
<div class="container"> |