ViewChild 装饰器用于获取模板视图中的元素或直接调用其组件中的方法。它支持 Type 类型或 string 类型的选择器,同时支持设置 read 查询条件,以获取不同类型的实例。

ViewChildren 装饰器是用来从模板视图中获取匹配的多个元素,返回的结果是一个 QueryList 集合。

static:true  用于页面初始化时就显示的数据,可以结合ngAfterViewInit使用

static:false 用于页面动态加载模板

 

@ViewChildren(ChildComponent,{static:true}) child
@ViewChildren(ChildrenComponent) children:QueryList<ChildrenComponent>

相关文章:

  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
  • 2021-11-19
  • 2021-09-22
  • 2022-02-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-12-04
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案