[英]Conditional in Angular 2 Component Selector
使用原生HTML input
标签,我可以对类型属性进行绑定,如:
<input [type]="_field.type">
input元素将根据_field.type
的值动态变化
但是,如果我有这样的多个组件,
@Component({
selector: 'field-option[type=options]',
templateUrl: ''
})
并使用它,像
<field-option [type]="_field.type">
它不起作用,它不绑定。
但是,我可以使用静态值,
<field-option [type]="options">
我想知道如何让它工作?
<input [type]="_field.type">
因为它是由浏览器处理的。
<field-option [type]="_field.type">
需要Angular支持,但那不是(还是?)实现的。
作为一种解决方法,你可以做类似的事情
<field-option *ngIf="_field.type='type1'" [type]="type1">
<field-option *ngIf="_field.type='type2'" [type]="type2">
我知道,麻烦: - /
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.