In my HTML code, some div
will display with the same condition. I set this condition to ng-show
for each div
.
<div ng-show="sameCondition1">...data1...</div>
...something else...
<div ng-show="sameCondition1">...data2...</div>
...something else...
<div ng-show="sameCondition1">...data3...</div>
AngularJS will create 3 watchers for each ng-show
. It can affect performance. Is there any way to decrease the number of watchers in this case?
ng-if
is better thenng-show
/ng-hide
. – Joblessng-show
creates a shallow watch, so it shouldn't be very expensive. If you want to optimise performance, eliminate deep watches and useng-if
to get rid of parts of the view that aren't needed at the moment where possible. – Heteronym