Angular生命周期
初始化组件生命周期执行顺序
constructor
->ngOnChanges
->ngOnInit
->ngDoCheck
->ngAfterContentInit
->ngAfterContentChecked
->ngAfterViewInit
->ngAfterViewChecked
->ngOnDestroy
DOM事件setTimeout,setInterval,ajax均会触发所有组件
ngDoCheck->ngAfterContentChecked->ngAfterViewChecked
当父组件包含另一个子组件时
父: ngOnChanges->ngOnInit->ngDoCheck
子: ngOnChanges->ngOnInit->ngDoCheck->ngAfterContentInit->ngAfterContentChecked
父: ngAfterContentInit->ngAfterContentChecked
子: ngAfterViewInit->ngAfterViewChecked
父: ngAfterViewInit->ngAfterViewChecked
变化检测时
父: ngDoCheck
子: ngDoCheck->ngAfterContentChecked
父: ngAfterContentChecked
子: ngAfterViewChecked
父: ngAfterViewChecked