What is the difference between functions ngAfterContentInit and ngAfterViewInit ?
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- How to update placeholder text in ng2-smart-table?
- How to instantiate Http service in main.ts manuall
- Angular: ngc or tsc?
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- Angular Material Stepper causes mat-formfield to v
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
- How can you get current positional information abo
- Angular material table not showing data
The following picture shows the order of the hooks. source: Angular Lifecycle Hooks
ngAfterContentInit
: This is called after components external content has been initialized.ngAfterViewInit
: This is called after the component view and its child views has been initialized.Content is what is passed as children usually to be projected at some
<ng-content>
element of a component.View is the template of the current component.
The view is initialized after the content and
ngAfterViewInit()
is therefore called afterngAfterContentInit()
.If you run this code, the output for
ngAfterViewInit - content
should benull
.More details about lifecycle hooks see https://angular.io/guide/lifecycle-hooks