Angular5--viewChild/viewChildren、contentChild/contentChildren使用规则小结

viewChild/viewChildren 是与<template>和component试图获取相关,获取view。

contentChild/contentChildren 是关于<ngcontent>内容获取相关,其中<ng-content>的select属性支持选择器区分映射进来的内容。

其中的viewChildren和contentChldren返回的是一个QueryList,是一个可订阅的列表,QueryList doc

猜你喜欢

转载自my.oschina.net/u/3554461/blog/1620978
今日推荐