I have a component. I need locate node in the template, append child
node to located node and dynamically create some component inside the child
node.
Is it possible with Angular 2?
If the node exists in the template statically the solution is known.
export class AppComponent {
@ViewChild("node", { read: ViewContainerRef }) nodeView;
..............
ngOnInit(): void {
this. componentResolver.resolveComponent(MyComponent)
.then((factory: ComponentFactory<MyComponent>) => {
MyComponent instance = this.nodeView.createComponent(factory);
});
}
}
In that way the problem is to find dynamic *equivalent*
<http://www.lingvo-online.ru/en/Search/Translate/GlossaryItemExtraInfo?text=%d1%8d%d0%ba%d0%b2%d0%b8%d0%b2%d0%b0%d0%bb%d0%b5%d0%bd%d1%82&translation=equivalent&srcLang=ru&destLang=en>
of
@ViewChild directive.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.