Angular ViewChildren不检索* ngTemplateOutlet绘制的子级

时间:2018-07-04 23:41:53

标签: angular viewchild

我正在将templateRef从一个组件传递到另一个组件,并希望访问在包装器组件内部绘制的组件

this.props.todos = [
          {
            task:'Daily meet',
            status:'incomplete'
          },
          {
            task:'Play videogame'
            status:'complete'
          }
]

this.props.todos.filter(todos => todos.status === 'complete').map((todos, i) => {

 return (<p>{todos.status} - Everythin Ok</p>)
 //here i got i = 0

}));
this.props.todos.filter(todos => todos.status === 'incomplete').map((todos, i) => {

  return (<p>{todos.status} - You have some task incomplete</p>)
  //and here i got i = 0 too i wanna this to be like the original array
}));

我想访问包装组件内部的HelloComponent

<wrapper [template]="myTpl"></wrapper>

<ng-template #myTpl>
  <hello></hello>
  <hello></hello>
</ng-template>

但始终为0。

如果我尝试访问app.component.ts中的内容,我将获得价值! 如何访问包装器组件内部的HelloComponent?

代码位于-https://stackblitz.com/edit/angular-gtwcx7

0 个答案:

没有答案