I can display the following Angular 2 component containing the input with the maxlength set:
@Component({ selector: 'app', template: '<input maxlength="10">', }) export class App { }
It works great. However, if I try to set maxlength through the 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 the input control.
Here's a live example (open the console to see the error).
source share