I want to modify the field of a component instance. For example, in test.component.ts:
@Component({
selector: 'test',
})
export class TestComponent {
@Input() temp;
temp2;
constructor(arg) {
this.temp = arg;
this.temp2 = arg * 2;
}
}
I want to set the values of temp and temp2 using the constructor. I know one approach is to use input property by doing something like:
<test [temp]='1'></test>
However, this is done after the constructing time and temp2 won't change accordingly. How can I supply component constructor argument from a consumer's point of view, such that the value of "temp" and "temp2" are set at constructing time?
Thanks!