[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.
[Angular] AfterContentChecked && AfterViewChecked的更多相关文章
- Angular2 - Starter - Component and Component Lifecircle Hooks
我们通过一个NgModule来启动一个ng app,NgModule通过bootstrap配置来指定应用的入口组件. @NgModule({ bootstrap: [ AppComponent ], ...
- Angular4学习笔记(九)- 生命周期钩子简介
简介 Angular 指令的生命周期,它是用来记录指令从创建.应用及销毁的过程.Angular 提供了一系列与指令生命周期相关的钩子,便于我们监控指令生命周期的变化,并执行相关的操作.Angular ...
- angular5理解生命周期
先来看下文档: 按照顺序有八个: 1.ngOnChanges()=>简单理解为当数据绑定输入属性的值发生变化时调用: 2.ngOnInit() => 在调用完构造函数.初始化完所有输入属性 ...
- Angular组件——组件生命周期(一)
组件声明周期以及angular的变化发现机制 红色方法只执行一次. 变更检测执行的绿色方法和和组件初始化阶段执行的绿色方法是一个方法. 总共9个方法. 每个钩子都是@angular/core库里定义的 ...
- Angular组件——组件生命周期(二)
一.view钩子 view钩子有2个,ngAfterViewInit和ngAfterViewChecked钩子. 1.实现ngAfterViewInit和ngAfterViewChecked钩子时注意 ...
- Angular生命周期理解
Angular每个组件,包含根组件和每一级的子组件,都存在一个生命周期,从创建,变更到销毁.Angular提供组件生命周期钩子,把这些关键时刻暴露出来,赋予在这些关键结点和组件进行交互的能力. 在An ...
- Angular 2 技能图谱skill-map
# Angular 2 技能图谱 ## 模块 ### 自定义模块 - 根模块 - 特性模块 - 共享模块 - 核心模块 ### 内置模块 - ApplicationModule 模块 - Common ...
- Angular 个人深究(四)【生命周期钩子】
Angular 个人深究(四)[生命周期钩子] 定义: 每个组件都有一个被 Angular 管理的生命周期. Angular 创建它,渲染它,创建并渲染它的子组件,在它被绑定的属性发生变化时检查它,并 ...
- 【17】进大厂必须掌握的面试题-50个Angular面试
我们整理了一份主要的Angular面试问题清单,分为三部分: 角度面试问题–初学者水平 角度面试问题–中级 角度面试问题–高级 初学者水平–面试问题 1.区分Angular和AngularJS. 特征 ...
随机推荐
- 多线程下,Python Sqlite3报[SQLite objects created in a thread can only be used...]问题
明明加了锁保护,还是出了下面的问题 ProgrammingError: SQLite objects created in a thread can only be used in that same ...
- linux c 学习笔记
gcc是linux c编译器 gcc -o o指定文件名或者会生成a.out文件 comment 注释 generate(生成) some simple ouput 使用标准 为C89
- 妙用next数组打表求最小循环节len
https://www.cnblogs.com/njczy2010/p/3930688.html https://blog.csdn.net/dominating413421391/article/d ...
- webstorm中.vue报错
1.webstorm中es6语法报错,解决方法: 打开 Settings => Languages & Frameworks => Javascript把 Javascript L ...
- Luogu P2590 树的统计(树链剖分+线段树)
题意 原文很清楚了 题解 重链剖分模板题,用线段树维护即可. #include <cstdio> #include <cstring> #include <algorit ...
- 洛谷—— P1908 逆序对
https://www.luogu.org/problem/show?pid=1908 题目描述 猫猫TOM和小老鼠JERRY最近又较量上了,但是毕竟都是成年人,他们已经不喜欢再玩那种你追我赶的游戏, ...
- 洛谷——P1478 陶陶摘苹果(升级版)
题目描述 又是一年秋季时,陶陶家的苹果树结了n个果子.陶陶又跑去摘苹果,这次她有一个a公分的椅子.当他手够不着时,他会站到椅子上再试试. 这次与NOIp2005普及组第一题不同的是:陶陶之前搬凳子,力 ...
- BZOJ 3505 [Cqoi2014]数三角形(组合数学)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3505 [题目大意] 给定一个nxm的网格,请计算三点都在格点上的三角形共有多少个. 注 ...
- MySort
实验概述: 本次试验的内容:模拟实现Linux下Sort -t : -k 2的功能.参考Sort的实现.提交码云链接和代码运行截图. 截图如下 实验过程 在实验课上真的很崩溃,可以说脑子里一团乱麻,下 ...
- 1.4(SQL学习笔记)分组、子查询、联结、组合查询
一.分组 建表及数据填充语句下载:链接: https://pan.baidu.com/s/1WHYafwqKJEKq1kDwCH_Zlg 提取码: 3wy4 1.1初识分组 分组是按照某一列,将该列中 ...