我可以呈現含有具有最大長度設定輸入以下角2成分的最大長度:角2結合到輸入或texarea
@Component({
selector: 'app',
template: '<input maxlength="10">',
})
export class App {
}
這工作得很好。但是,如果我嘗試通過綁定設置最大長度,就像這樣:
@Component({
selector: 'app',
template: '<input [maxlength]="maxLength">',
})
export class App {
maxLength = 10;
}
或者這樣:
template: '<input maxlength="{{maxLength}}">',
我得到以下錯誤:
"Template parse errors: Can't bind to 'maxlength' since it isn't a known property of 'input'."
爲什麼? maxlength
是輸入控件的完全有效屬性。
這是一個live example(打開控制檯查看錯誤)。從Angular documentation
非常感謝。這是什麼意思,它是怎麼發生的,是否有關於它的文檔等?我只需要知道如何向我的同事解釋這一點。 – Mud
你可以在[angular文檔](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#other-bindings)上閱讀有關屬性綁定,乾杯! –