Angular 2 @ Error entering number
I have the following component:
<component value="3"></component>
And component code:
private _value:number;
get value(): number {
return this._value;
}
@Input()
set value(value: number) {
console.log(value);
console.log(typeof value);
this._value = value;
}
Magazine:
3
string
But if I bind a property like:
<component [value]="variable1"></component>
In this case, I get a number if variable1 is a type number.
3
number
I know there is no magic with typescript, but is this true? Should Angular input decoder do the conversion?
I check types in setters, but I get errors when compiling typescript.
I do not want to use the any type in gettes and setter.
Any elegant solution?