The talk from here.

1. The lifecycle in Angular component:

constructor vs ngOnInit:

Constructor: only used for injection.

ngOnInit: for data initlization.

About ngOnInit: 

I am not sure the example is good or not. Because it is not a good choice to use 'document.querySelector'.

this.elDuceDateContainer = document.querySelector('.dueDatePopover-container')

I would rather use 'ref' or '@ViewChild'. But might be it is a good adivse that avoid init too many variable in ngOnInit if not going to use right away.


You have to know that why change detection works. It handle async code and setTimeout, setTimeInterval, DOM event, mouse event... they are all async opreations.

So it will trigger change detection.

If you have to use setTimeout in your component, and you don't want change detection to detect the changes, you can use NgZone to make it run outside the change detection.

constructor(private ngZone: NgZone) {}

ngAfterViewInit() {
this.ngZone.runOutsideAngular(() => this.paint());
}

Noramlly I won't use any jQuery plugin. But take this as an advise.

最新文章

  1. 【转】gc日志分析工具
  2. jquery操作radio单选按钮、checked复选框。
  3. 光流算法:Brox算法
  4. protobuf的安装和使用
  5. delphi 插入 HTML代码 播放器
  6. JavaScript面向对象精要
  7. Python 3
  8. Android ListView Adapter的getItemViewType和getViewTypeCount多种布局
  9. 由浅入深的讲述Get和Post的区别
  10. Docker环境编译时的错误记录
  11. 2018-2019-2 网络对抗技术 20165320 Exp2 后门原理与实践
  12. 配置ASM以及创建恢复目录
  13. 渗透中Meterpreter基本操作和对应的windows上的排查或者现象
  14. C#之使用AutoUpdater自动更新客户端
  15. Spring Cloud限流思路及解决方案
  16. Oracle游标解析
  17. angular 程序架构
  18. EasyMock set方法报错: java.lang.AssertionError
  19. bzoj 1131 简单树形dp
  20. ajax请求步骤

热门文章

  1. Android应用开发-广播和服务
  2. Django的命令
  3. iOS ERROR: unable to get the receiver data from the DB 解决方式
  4. c编程:僵尸吃大脑
  5. JS数据类型的转换规则
  6. 4、python基本知识点及字符串常用方法
  7. 【Codeforces Round #433 (Div. 1) B】Jury Meeting
  8. 步步为营(十五)搜索(一)DFS 深度优先搜索
  9. WCF学习笔记——WCF基础
  10. cookie和session使用