Is it possible to modify the field of a component instance? Let's consider an example in test.component.ts:
@Component({
selector: 'test',
})
export class TestComponent {
@Input() temp;
temp2;
constructor(arg) {
this.temp = arg;
this.temp2 = arg * 2;
}
}
I am looking to set the values of temp and temp2 using the constructor. One common approach is to use input property like this:
<test [temp]='1'></test>
But this method modifies the properties after construction, causing temp2 not to update accordingly. What can be done to provide constructor arguments for a component from the consumer's perspective so that "temp" and "temp2" are set during construction?
Thank you!