I am new to Angular and am trying to get a hold of life cycle hooks. However, I am confused because what I see in my code doesn't go along with the documentation.
I have following code in my component class:
ngOnInit() {
console.log("ngOnInit", this.personList);
this.person = this.pService.getName();
}
ngOnChanges() {
console.log("ngOnChanges", this.personList, arguments);
}
ngDoCheck() {
console.log("ngDoCheck", this.personList, arguments);
}
ngAfterContentInit() {
console.log("ngAfterContentInit", this.personList, arguments);
}
ngAfterViewInit() {
console.log("ngAfterViewInit", this.personList, arguments);
}
ngAfterViewChecked() {
console.log("ngAfterViewChecked", this.personList, arguments);
}
ngAfterContentChecked() {
console.log("ngAfterContentChecked", this.personList, arguments);
}
ngOnDestroy() {
console.log("ngOnDestroy", this.personList, arguments);
}
changeclr() {
this.person = this.name === 'Saurabh' ? 'Navanshu' : 'Saurabh';
}
The docs here says ngOnchanges gets triggered before ngonInit but I can't see any logs for ngOnChanges while application loads.
The docs also says ngOnChnages runs while data-bound property changes. Is it specific to properties set using @Input, because I can't see any logs while I change this.person using my changclr method.
Am I getting something wrong here ?