3 ms·
ng-if is also useful in these cases. https://docs.angularjs.org/api/ng/directive/ngIf https://docs.angularjs.org/api/ng/directive/ngIf
by likeclockwork 12y ago
ng-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.