[Angular] @ViewChild and template #refs to get Element Ref
We can use @ViewChild with component:
- @ViewChild(AuthMessageComponent) message: AuthMessageComponent;
- //....
- ngAfterContentInit() {
- if (this.message) {
- this.message.days = ;
- }
- }
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.
- <input type="email" name="email" ngModel #email>
- @ViewChild('email') email: ElementRef;
- // ....
- ngAfterViewInit() {
- console.log(this.email); // ElementRef
- }
[Angular] @ViewChild and template #refs to get Element Ref的更多相关文章
- angular ViewChild ContentChild 系列的查询参数
官方说明 官方文档 在调用 NgAfterViewInit 回调函数之前就会设置这些视图查询. 元数据属性: selector - 用于查询的指令类型或名字. read - 从查询到的元素中读取另一个 ...
- [Angular 2] Create template with Params
Angular 2 templates have a special let syntax that allows you to define and pass a context when they ...
- [Angular 2] Passing Template Input Values to Reducers
Angular 2 allows you to pass values from inputs simply by referencing them in the template and passi ...
- Angular ViewChild
viewchild // 使用方法 git clone https://git.oschina.net/mumu-osc/learn-component.git cd learn-component ...
- [Angular] @ViewChild read custom directive and exportAs
For example we have a component: <Card ></Card> And a driective: <Card highlighted> ...
- [Angular] ViewChild 'read' option
It is not clear in the Docs about {read: xx} option for @ViewChild. Based on the Source code, @ViewC ...
- [Angular 2] Share Template Content In Another Template With Content Projection <ng-content>
Angular 1 provided a mechanism to place content from your template inside of another template called ...
- [Angular] Test component template
Component: import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output } from '@angular ...
- Angular ViewChild & ViewChildren
基础 ViewChild ViewChild 装饰器用于获取模板视图中的元素或直接调用其组件中的方法.它支持 Type 类型或 string 类型的选择器,同时支持设置 read 查询条件,以获取不同 ...
随机推荐
- Android中Alarm的机制
本次给大家分析的是Android中Alarm的机制所用源码为最新的Android4.4.4.首先简单介绍如何使用Alarm并给出其工作原理,接着分析Alarm和Timer以及Handler在完成定时任 ...
- ORACLE10g R2【单实例 FS→单实例FS】
ORACLE10g R2[单实例FS→单实例FS] 本演示案例所用环境: primary standby OS Hostname pry std OS Version RHEL5.8 RHEL5. ...
- [Angular] Protect The Session Id with https and http only
For the whole signup process. we need to Hash the password to create a password digest Store the use ...
- [Spark源代码剖析] DAGScheduler划分stage
转载请标明出处:http://blog.csdn.net/bigbigdata/article/details/47293263 本文基于Spark 1.3.1 先上一些stage相关的知识点: DA ...
- js进阶 14-3 如何接收load函数从后台接收到的返回数据
js进阶 14-3 如何接收load函数从后台接收到的返回数据 一.总结 一句话总结:load方法的回调函数的参数即可接收从后台的返回数据. 1.load方法的回调函数的参数是什么? 语法:load( ...
- report_timing
report_timing -max_path 2 会报告两条路径,但不一定是最差的路径 report_timing -nworst 2 -max_path 2 会报告两条最差的路径
- 内存、时间复杂度、CPU/GPU以及运行时间
衡量 CPU 的计算能力: 比如一个 Intel 的 i5-2520M @2.5 Ghz 的处理器, 则其计算能力 2.5 * 4(4核) = 10 GFLOPS FLOP/s,Floating-po ...
- HttpClient请求发送的几种用法二:
public class HttpClientHelper { private static readonly HttpClientHelper _instance = new H ...
- mootools常用特性和示例(基础篇2)
接着上一篇:mootools常用特性和示例(基础篇1) 1.表单操作 html: <form id="myForm" action="submit.php" ...
- 每日技术总结:promise,express route,评分,local storage商品浏览历史,
最近正在用Vue做一个电商项目.利用工作前后空隙时间. 1.promise的使用 点这里 如何在实际项目中使用Promise 2. Express Route 前后端传参的两种方法 (1)req.pa ...