I found a few questions regarding ngShow
vs ngIf
but nothing that addressed my use case all that well.
- Alternative to ng-show/-hide or how to load only relevant section of DOM
- what is the difference between ng-if and ng-show/ng-hide
- When to favor ng-if vs. ng-show/ng-hide?
I understand the differences between the two directives but for an application with many conditional UI elements (content, toolbar buttons, dropdowns, form fields, etc - some of which are in ngRepeats
) which is the better choice - ngShow
or ngIf
? As the user navigates the application and loads different content into the UI, these conditions will be evaluated so this will happen regularly as opposed to one time as it might with something like user preferences or permissions. Also, much of the content that is conditionally displayed contains {{bindings}}
. The number of extra watches is my concern with ngShow
while the large number of DOM manipulations concerns me with ngIf
.
Is there a best practice or guidance for this type of situation? Is there some threshold where one makes sense over the other? Or is it simply a matter of trying both to determine the performance impacts of each (easier said than done)?