4 ms·
I used debouncing inside a watch expression. Really useful. Another performance trick. If you use ng-hide/show to hide a long list, then make a dummy function
by hmottestad 12y ago
I used debouncing inside a watch expression. Really useful.
Another performance trick.
If you use ng-hide/show to hide a long list, then make a dummy function that takes the list and the variable for the ng-hide/show and only returns the list when the ng-show is true. This way you don't spend valuable time rendering something that will have css hidden.
- deleted 12y ago[deleted]
- likeclockwork 12y agong-if is also useful in these cases. https://docs.angularjs.org/api/ng/directive/ngIf https://docs.angularjs.org/api/ng/directive/ngIf
- aarongray 12y agoYeah, and the good thing about ng-if compared to ng-show is that it removes the elements from DOM, rather than just hiding them, which is better for large datasets.
- likeclockwork 12y agoAlso, maybe this isn't a common issue and would be solved by better designed models but.. using an ng-repeat against a list with some heterogeneous data.. ng-if works well to show only the UI components that apply to the object in question without rendering things for no reason and then hiding them. For example if you have a list of objects where some particular action might apply only to a portion of them.
- aarongray 12y agoI like it. We have seen a significant difference in performance in holding objects in our JS but not putting them in the DOM until the user needs to see them. I think the more you can remove from the DOM, the better.