问题:
Angular provides life cycle hook ngOnInit by default. Angular默认提供生命周期挂钩ngOnInit 。
Why should ngOnInit be used, if we already have a constructor ? 如果我们已经有了constructor ,为什么还要使用ngOnInit呢?
解决方案:
参考一: https://stackoom.com/question/2Q3mM/构造函数和ngOnInit之间的区别参考二: https://oldbug.net/q/2Q3mM/Difference-between-Constructor-and-ngOnInit
来源:oschina
链接:https://my.oschina.net/u/4428122/blog/4317556