zoukankan      html  css  js  c++  java
  • angular 的 @ViewChild 和 @ViewChildren 区别

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

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

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

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

     

    @ViewChildren(ChildComponent,{static:true}) child
    @ViewChildren(ChildrenComponent) children:QueryList<ChildrenComponent>
  • 相关阅读:
    CentOS-Docker安装RabbitMQ集群(rabbitmq:3.7.16-management)
    Xcode Shortcuts
    In App Purchase
    CoreData
    Sandbox 文件存放规则
    在 mac os 上搭建 git server
    Git
    Git and Xcode
    心算技巧
    AppleScript
  • 原文地址:https://www.cnblogs.com/lskzj/p/12022432.html
Copyright © 2011-2022 走看看