What is the difference between ngOnInit(), ngAfterViewInit(), ngafterContentInit(), ngAfterViewChecked() and a constructor()?
问题 What is the difference between ngOnInit (), ngAfterViewInit (), ngafterContentInit (), ngAfterViewChecked () and a constructor ()? How do we implement them in the Angular 2? What are their purposes and usages? Where all will it be useful for implementing them? Thanks. 回答1: Those are life cycle hooks that you can tap into to perform operations and different times of a components life cycle. There is an excellent guide on the topic in the official angular documentation: https://angular.io/guide