[英]How to bind custom error to a Template Driven form input field in angular5
[英]Bind @Input() field in components template
我有這樣的組件:
@Component({
selector: 'foo',
template: '<h1>{{bar}}</h1>'
})
export class FooComponent {
@Input()
bar: string;
}
現在我想在其他地方使用這個組件(假設一切都配置正確):
<foo [bar]="Test"></foo>
輸出是:
<h1></h1>
你知道為什么嗎? 為什么@Input()
字段不能綁定在它的組件模板中?
版本:Angular 2.0最終版本
它應該是
<foo [bar]="'Test'"></foo>
要么
<foo bar="Test"></foo>
否則將分配父組件的屬性Test
的值,這可能是undefined
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.