I\'m trying to detect when the value of an input changed in a directive. I have the following directive:
You can also use HostListener. For more information about HostListener, you can go through this link. Here is the code.
import {Directive, ElementRef, HostListener} from '@angular/core';
@Directive({
selector: '[number]'
})
export class NumberDirective {
@Input() public number: any;
@Input() public input: any;
constructor(private el: ElementRef) {}
@HostListener('change') ngOnChanges() {
console.log('test');
}
}