I can render the following Angular 2 component containing an <input>
with a maxlength
set:
@Component({
selector: 'app',
template: '<input maxlength="10">',
})
export class App {
}
This works fine. However, if I try to set the maxlength
via a binding, like this:
@Component({
selector: 'app',
template: '<input [maxlength]="maxLength">',
})
export class App {
maxLength = 10;
}
Or like this:
template: '<input maxlength="{{maxLength}}">',
I get the following error:
"Template parse errors: Can't bind to 'maxlength' since it isn't a known property of 'input'."
Why? maxlength
is a perfectly valid property of an <input>
element.
Here's a live example (open console to see error).