加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 递归放置的组件不显示

发布时间:2020-12-17 10:16:49 所属栏目:安全 来源:网络整理
导读:我有以下组件,它为数组中的每个元素显示自己类型的子组件. @Component({ selector:'pane',template: ` pane [item]="item" div pane *ngFor="#subItem of item.subItems" [item]="subItem"/pane /div div innerHtml="item.getContent()"/div /pane `)} expor
我有以下组件,它为数组中的每个元素显示自己类型的子组件.
@Component({
  selector:'pane',template: `
       <pane [item]="item">
           <div> 
               <pane *ngFor="#subItem of item.subItems" [item]="subItem"></pane>
           </div>
           <div innerHtml="item.getContent()"></div>
       </pane>
   `
)}   
export class Pane {
  @Input() item: any;
}

但是ngFor中的窗格组件没有按预期显示 – 我看到正确数量的窗格元素,但它们没有填充模板内容.

这是因为您需要在装饰器的directives属性中声明组件自己的类型,就像使用任何其他指令一样.

添加:

directives: [Pane]

到您的组件元数据导致预期的行为.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读