call Ng-repeat as few as possible
Ng-repeat By default will create a lot of listeners, so when the amount of data is very large, this very consumption of page performance, I feel only when it is necessary to update the data list often need to use ng-repeat, or put so many listeners there is also a waste, this time can be used with NG to bring the $ Interpolate service to parse a code fragment, similar to a static template engine, its internal mainly relies on the NG core parsing service $parse, and then the code fragments after the filling data directly assigned to a one-time model can be.
try to write the native grammar in the instruction.
Although NG provides a number of instructions such as ng-show,ng-hide, it is actually useful to show or hide a code fragment based on the true,false of the model, although it is possible to implement the business requirements very quickly, but these instructions will add the listener by default. If these snippets exist in a large instruction, the better way is to write them in the command link. Show (),. Hide () These similar JQ methods are better controlled, which saves the number of listeners, similar to the own event commands, In fact, these can be used in the peripheral instructions by using AddEventListener to bind the event, anyway, before writing the code, it is best to think about how to make the number of listeners the least, so as to improve the overall performance of the page.
use less filters in the page
When the filter is added behind the model in the page, this causes the current model to run two times in the $digest, causing unnecessary performance waste. The first time in the $watchers detection task changes, the second occurs when the model value modification, so as to minimize the use of inline filter syntax, The page performance is affected very much like the following
It is recommended to use the $filter service to invoke a filter function in the background, which can significantly improve the performance of the page, the code is as follows
$filter (' filter ') (array, expression, comparator);
Summary
These are some of the tips for improving the performance of NG projects, although NG is powerful, but nonstandard code can also disrupt its performance, so it's best to conceive where the listener is not needed before writing the code.
Some optimization tips for Angularjs