博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Angular] @ViewChild and template #refs to get Element Ref
阅读量:4678 次
发布时间:2019-06-09

本文共 499 字,大约阅读时间需要 1 分钟。

We can use @ViewChild with component:

@ViewChild(AuthMessageComponent) message: AuthMessageComponent;//.... ngAfterContentInit() {    if (this.message) {      this.message.days = 30;    }  }

By doing this, we actually can access component's prop and events.

 

If we want to get component DOM node, what we can do is using template ref.

@ViewChild('email') email: ElementRef;// ....  ngAfterViewInit() {    console.log(this.email); // ElementRef  }

转载于:https://www.cnblogs.com/Answer1215/p/6417985.html

你可能感兴趣的文章
TCP/IP系列——长连接与短连接的区别
查看>>
Linux基础——常用命令
查看>>
Python学习笔记三(文件操作、函数)
查看>>
二进制分组
查看>>
[ACM] POJ 1068 Parencodings(模拟)
查看>>
Drools只执行一个规则或者执行完当前规则之后不再执行其他规则(转)
查看>>
冰点还原8.57 官方中文版下载
查看>>
poj 2236(并查集的应用)
查看>>
C 栈 链式存储
查看>>
Java 游戏报错 看不懂求教
查看>>
APP自动化测试
查看>>
HTML中让表单input等文本框为只读不可编辑的方法
查看>>
nodejs做中间层,向后端取数据
查看>>
IntelliJ IDEA 2017 MySQL5 绿色版 Spring 4 Mybatis 3 配置步骤详解(二)
查看>>
Design Pattern --- Strategy
查看>>
mui列表跳转到详情页优化方案
查看>>
一些简单有用的方法合集
查看>>
Neutron 架构 - 每天5分钟玩转 OpenStack(67)
查看>>
详解JS设计模式
查看>>
CPSR寄存器
查看>>