Here is the component in question:
<component value="3"></component>
This is the code for the component:
private _value:number;
get value(): number {
return this._value;
}
@Input()
set value(value: number) {
console.log(value);
console.log(typeof value);
this._value = value;
}
The output from the console logs shows:
3
string
However, when binding the property like this:
<component [value]="variable1"></component>
If variable1 is of type number, the result changes to:
3
number
Is it expected behavior for Angular Input decorator to handle the conversion automatically?
Despite checking types in the setters, Typescript compilation errors arise.
Avoiding the use of 'any' type in getters and setters, what would be a more elegant solution?