zl程序教程

您现在的位置是:首页 >  前端

当前栏目

Angular html 页面里的井号 #

AngularHTML 页面
2023-09-14 09:04:00 时间

例子:

<input #inp (change)="foo = inp.value">

listenes to the change event and calls onChange() and passes the inputs value property

监听 change 事件,通过 # 后面的名称,再加上 .value 获取 DOM 元素的输入值。
看下面这个例子:

<h1>Jerry</h1>
<input #inp (change)="foo = inp.value">
<div>{{ foo }}</div>

Component 里的定义:

最终效果:

更多Jerry的原创文章,尽在:“汪子熙”: