Vadim Peretokin
Vadim Peretokin

Reputation: 2846

How to hook on @Input property change?

I have a data binding from parent to child component and the childs template renders the data.

How can I act, in the child, on the event of the data being changed so I can do stuff with it before I render it?

Upvotes: 1

Views: 723

Answers (1)

Kld
Kld

Reputation: 7068

Instead of using

@Input() myInputVariable;

You can intercept the input property changes with a setter, you can read more here

@Input()
set myInputVariable(value: boolean) {
    // Do Something here
}

Upvotes: 3

Related Questions