I have an Angular component with two input properties. I would like to call a method when both properties are set, is there any event I can use?
export class ProductComponent implements OnInit {
_product: Product;
@Input() set product(value: Product) {
_product = value;
}
_attributeType: any;
@Input() set attributeType(value: any) {
_attributeType = value;
this.doSomeWorkWhenBothProductAndAttributeTypeAreSet();
}
doSomeWorkWhenBothProductAndAttributeTypeAreSet() {
}
}
In the above code sample, I would like to call doSomeWorkWhenBothProductAndAttributeTypeAreSet() when product and attribute type have been assigned. I tried calling the method after setting the second property but sometimes the product takes longer to assign so does not work as expected.