https://next.plnkr.co/edit/0LHeJ3Fyz5gdjJqQ?open=lib%2Fapp.ts&deferRun=1 Here's a plunkr. It's just for example.
In real project i got something like
<input [(ngModel)]='_data.name' [name]='name' />
I pass some data for input by using ngOnInit lifehook
And i cant understand why my ngOnChanges hook doesn't trigger changes when i write something in my <input>
The _data takes data from json/server by using services http request, then i get name in my <input>, or something on
The question is: how to detect changes with ngOnChange lifehook in my situation
I try to set [name]='name' and then take it using @Input like that
@Input() name: string;
Then in ngOnChanges
ngOnChanges(changes: SimpleChanges) {
console.log(changes.name.currentValue);
}
Why i do not see anything in my console? Why ngOnChanges is not working this way? I need to take value from my input, then detect it changes using ngOnChanges No errors in console, no data, just nothing, empty
ngOnChanges?, instead listenonChange,inputorkeyupevents on your input - Artyom Amiryan