I'm not 100% clear on your needs, but let me try anyway.  It sounds to me 
like you need nested components.  You could nest your components within 
each other with an *ngIf on them to control their display.  Instead of 
searching the dom tree for them, you toggle a boolean property to display 
them.

Hopefully, that helps.



On Friday, July 15, 2016 at 7:58:16 AM UTC-7, Paul Belowee wrote:
>
> 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.

Reply via email to