[Angular] Some performance tips
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.
[Angular] Some performance tips的更多相关文章
- Android 性能优化(19)*代码优化11条技巧:Performance Tips
Performance Tips 1.In this document Avoid Creating Unnecessary Objects 避免多余的对象 Prefer Static Over Vi ...
- SQL Server performance tips
Refer to: http://harriyott.com/2006/01/sql-server-performance-tips A colleague of mine has been look ...
- Performance tips
HTML5 Techniques for Optimizing Mobile Performance Scrolling Performance layout-performance
- Json.NET Performance Tips
原文: http://www.newtonsoft.com/json/help/html/Performance.htm To keep an application consistently fas ...
- [Angular] Increasing Performance by using Pipe
For example you make a function to get rating; getRating(score: number): string { let rating: string ...
- 翻译--Blazing fast node.js: 10 performance tips from LinkedIn Mobile
1.避免使用同步代码: // Good: write files asynchronously fs.writeFile('message.txt', 'Hello Node', function ( ...
- [Javascript]3. Improve you speed! Performance Tips
/** Let inheritance help with memory efficiency */ function SignalFire(ID, startingLogs){ this.fireI ...
- 10个加速Table Views开发的Tips(转)
本文由CocoaChina译者yake_099(博客)翻译,作者:David McGraw原文:10 Actionable Performance Tips To Speed Up Your Tabl ...
- 【原创】大数据基础之Hive(5)性能调优Performance Tuning
1 compress & mr hive默认的execution engine是mr hive> set hive.execution.engine;hive.execution.eng ...
随机推荐
- adapter-自定义adapter的典型写法
文章参考 http://www.cnblogs.com/mengdd/p/3254323.html import android.content.Context; import android.vie ...
- Linux在应用层读写寄存器的方法
可以通过操作/dev/mem设备文件,以及mmap函数,将寄存器的地址映射到用户空间,直接在应用层对寄存器进行操作,示例如下: #include <stdio.h> #include &l ...
- Python的数组合并
https://blog.csdn.net/hustqb/article/details/78090365 TypeError: can only concatenate list (not &quo ...
- 浅析C#组件编程中的一些小细节
控件与组件的区别(Control&Component的区别) 作者:作者不详 发布日期:2011-06-30 12:08:41 控件与组件的区别(Control&Component的 ...
- hadoop组件及其作用
1.hadoop有三个主要的核心组件:HDFS(分布式文件存储).MAPREDUCE(分布式的计算).YARN(资源调度),现在云计算包括大数据和虚拟化进行支撑. 在HADOOP(hdfs.MAPRE ...
- WIN7/8/10下批处理提权工具
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 自动添加批处 ...
- 软件——机器学习与Python,输入输出的用法
转自:http://www.cnblogs.com/graceting/p/3875438.html 输入很简单 x = input("Please input x:") Plea ...
- bootstrap课程5 bootstrap中的组件使用的注意事项是什么
bootstrap课程5 bootstrap中的组件使用的注意事项是什么 一.总结 一句话总结: 1.img-responsive的作用是什么(其实还是要多看手册)? 看起来像width=100%的效 ...
- 杭电ACM1197——Specialized Four-Digit Numbers
题目的意思是从2992開始的四位数.每个四位数的10.12,16进制的数的每一位加起来都相等,就输出该数. 非常easy的一道题目. 以下的是AC的代码: #include <iostream& ...
- ado连接mysql和ORACLE
------mysql strConnect.Format("Provider=MSDASQL.1;Driver={%s};Server=%s;DataBase=%s;UID=%s;PWD= ...