Reputation: 165
If I use an AngularJS directive with a static value, let's say:
<input type="text" ng-readonly="true" />
My question around this:
Will this directive be re-evaluated on AngularJS cycles leading to a drop on performance? (think on a heavier scenario)
Upvotes: 2
Views: 77
Reputation: 67296
Will this directive be re-evaluated on AngularJS cycles
:
Yes, the value of ng-readonly
is an Angular Expression and this expression could be a more complex ternary or function reference. So, the directive must do dirty checking on it (for the more complex cases).
leading to a drop on performance
This depends on many things and should be tested and benchmarked before making assumptions. A lot of dirty-checking can happen without any noticeable performance drop.
Since Angular 1.3, you can use the bind-once syntax (::
) to possibly not add the value to the watch queue, but I'm not sure about how this would work with true
:
<input type="text" ng-readonly="::true" />
Upvotes: 1