[英]Angular2: Template variables with custom values
I understand that I can assign local template variables to hold element reference like following 我知道我可以分配本地模板变量来保存元素引用,如下所示
<input #myInput />
But can I declare a variable with custom value? 但是我可以声明具有自定义值的变量吗?
For example: 例如:
<!-- Somewhere I do #obj = model.data.something -->
<input [(ngModel)]="obj.inputA" >
<input [(ngModel)]="obj.inputB" >
Instead of doing 而不是做
<input [(ngModel)]="model.data.something.inputA" >
<input [(ngModel)]="model.data.something.inputB" >
You can't declare a variable with a custom value. 您不能使用自定义值声明变量。
A template variable 模板变量
exportAs: 'xxx'
property #myVar="xxx"
exportAs: 'xxx'
来引用特定指令(如果将一个或多个应用于元素) exportAs: 'xxx'
属性exportAs: 'xxx'
#myVar="xxx"
*ngFor="let x of y; let i=index"
*ngFor="let x of y; let i=index"
结构性指令声明*ngFor="let x of y; let i=index"
There is an open issue to support assigning custom expressions as well https://github.com/angular/angular/issues/2451 还有一个开放的问题来支持分配自定义表达式https://github.com/angular/angular/issues/2451
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.