Angular allows us to declare multiple component life cycle hooks. For example, in the companion source code, the Movie component extends the OnInit interface, which declares the ngOnInit method. The ngOnInit method is one of the available component life cycle hooks in Angular:
- The constructor of the component class is called before any other component life cycle hook. The constructor is the best place to inject dependencies.
- The ngOnInit method is invoked immediately after the constructor and after the ngOnChange is triggered for the first time, which is the perfect time for initialization work.
- The ngOnChanges method is invoked first when the value of a bound property changes. It executes every time the ...