[Angular] AfterContentChecked && AfterViewChecked
AfterContentChecked & AfterViewChecked are called after 'OnChanges' lifecycle. And each time 'ngOnChanges' triggered, ngAfterContentChecked and ngAfterViewChecked will also be called. Which means we should be careful what we do in those lifecycle should be light weight, no havey calculation.
AfterContentChecked:
Here is the last chance you can modify the data before it rendered to the DOM. But there is one restriction that you cannot modify the data which passed to the content projection component:
<course-card [course]="course"> <course-image [image-url]="imageURL"></course-image> </course-card>
ngAfterContentChecked () { this.course.description = 'something new'; // OK this.course.imageUrl = "" // error }
You cannot modify imageUrl prop since it is used by the content projection.
AfterViewChecked:
After the whole template has been checked, this lifecycle will be called, it means you cannot modify the @Input data any more. Otherwise it will throw error.
Here what you can do is doing some DOM animation, foucs management... because DOM is already renderered to the screen.
相关文章
- 设计模式-责任链模式&策略模式
- ECCV 2022 | 仅用全连接层处理视频数据,美图&NUS实现高效视频时空建模
- 剑指offer:Python 二进制中1的个数 &0xffffffff是什么意思?
- 限流&熔断的考量
- 使用ModSecurity & ELK实现持续安全监控
- 一年半经验前端社招7家大厂&独角兽全过经历 | 掘金技术征文
- Linux中&&、&、|、||等特殊符号的作用
- Linux系统自带Python2&yum的卸载及重装
- ST&Sensory&DSPC Joint Webiner
- 清华&商汤提出了神经SDF!从多个照明条件下单视图纯阴影或RGB图像重建!论文/代码速递2022.11.29!
- App Cleaner & Uninstaller for mac(最佳卸载程序和清洁助手) 中文
- 中山大学&阿里巴巴提出:用于基于Aspect的情感分析的关系图注意网络(GAT)
- 微信公众平台开发(二)——自定义菜单、模板消息&微信素材
- Angular 项目中 angular.json builder 字段的可选项介绍
- MySQL单表&约束&事务
- 社区(php&&mysql)六
- ASP编程入门进阶(十三):Ad&ContentRotator