multiple @input variables

20 views
Skip to first unread message

Reza Razavipour

unread,
Aug 16, 2017, 1:12:21 PM8/16/17
to Angular and AngularJS discussion
If I have multiple Input parameters for a component will I need a ngOnChanges for each of the input parameters or
how will I tell them apart?

Sander Elias

unread,
Aug 16, 2017, 11:07:01 PM8/16/17
to Angular and AngularJS discussion
Hi Reza,

Put this in your component, and you will be able to figure it out:
ngOnChanges(changes: SimpleChanges) {
  console.log(`ngOnChanges`);
  for (let key in changes) {
    console.log(`${key} changed.`, changes[key].currentValue}, changes[key].previousValue);
  }
}

Regards
Sander
Reply all
Reply to author
Forward
0 new messages