ViewChildren for ng-template

后端 未结 1 625
轻奢々
轻奢々 2020-12-11 02:06

I have a angular2 component for which the template look like this:

&
相关标签:
1条回答
  • 2020-12-11 02:37
    @ViewChildren(TemplateRef) templates: QueryList<TemplateRef>;
    
    ngAfterViewInit() {
      console.log(this.templates.toArray());
    }
    

    or

    @ViewChild('left') left:TemplateRef;
    @ViewChild('right') right:TemplateRef;
    
    ngAfterViewInit() {
      console.log(this.left, this.right);
    }
    
    0 讨论(0)
提交回复
热议问题