[Angular] ViewChild 'read' option
2024-09-01 17:12:18
It is not clear in the Docs about {read: xx} option for @ViewChild.
Based on the Source code, @ViewChild as view as Component, ElementRef, TemplateRef.
For example, we have:
<one></one>
@ViewChild(OneComponent)
one: OneComponent;
ngAfterViewInit() {
console.log('after', this.one);
}
Now we read 'OneComponent' as a component, if we want to read it as ElementRef, we can do:
@ViewChild(OneComponent, {read: ElementRef})
one: ElementRef;
[NOTICE]:
One thing to notice is that @ViewChild is only for viewing the its own component tamplate, you cannot view its child component template or parent component template
最新文章
- centos6.6 安装jdk1.7
- PAT 1039. 到底买不买(20)
- 使用Ninject进行DI(依赖注入)
- Python + OpenCV2 系列:2 - 图片操作
- 手动给控制器添加xib
- springmvc之interceptor(拦截器)
- 设计前沿:25款精妙的 iOS 应用程序图标
- ASP.NET XML与JSON
- Rsync同步工具安装文档
- BZOJ 2809 APIO2012 dispatching Treap+启示式合并 / 可并堆
- windows phone (21) Grid元素的Background和Clip
- IBATIS事务处理 - - 博客频道 - CSDN.NET
- Day8 接口与归一化设计
- for break
- 【特征提取】MultiBlock-LBP特征
- HDOJ 2001 计算两点间的距离
- SpringMVC RestTemplate的几种请求调用
- supervisor管理uwsgi
- Hdu4903 The only survival
- Java基础(十四):泛型