Reputation: 15696
Lets say I have an HTML div containing numerous form elements that are all watching model values, if I use ng-show, ng-if, or ng-switch on the div to hide it, will this stop angular JS from doing dirty checking on the form elements and thus improve the performance of my app?
I figure that if the bound elements are not visible then there's no need for angular to be checking the values bound to them.
Upvotes: 4
Views: 1268
Reputation: 9457
ng-show
and ng-hide
will only set a CSS display
style, and will still process the bindings. ng-switch
, however, will completely comment out the cases that do not apply, which in turn means bindings in those are not processed. I agree, however, with Edmondo1984's reply, that I doubt you should base your choices on this. Do not rewrite your ng-show
s as ng-switch
es because of this!
You can verify this with the Chrome extension Batarang, the performance tab shows which watches are active.
Upvotes: 4