Angular 2- ngOnChanges only for a specific binding

As Eric stated, the ngOnChanges method will be called on every updates of your @Inputs.

If you want to detect only the updates of the @Input "a" you could use a setter:

export class SubComponent {
  @Input()
  set a(a:string) {
    this._a = a;
    console.log('a updated');
  }

  @Input()
  b:any;

  (...)
}

See this plunkr: https://plnkr.co/edit/UKyRiq?p=preview.


Use, (You will get both variables value in agrs)

ngOnChanges(...args: any[]) {  
        console.log('onChange fired');
        console.log('changing', args); // so can access both variables here in args.
        console.log('changing', args[0]); //a's current and previous value if i'm not wrong.
        console.log('changing', args[1]); //b's current and previous value if i'm not wrong.
 }