Trimming your watch list with lazy binding
A continuing gripe with AngularJS as a framework is targeted at the perceived inefficiencies of its data binding facilities. While it is true that it can be easy to fall into bad performance traps, a developer who understands what is going on under the hood and is able to make decisions accordingly can wield AngularJS against any architectural challenge.
Bind once is one of the more heralded introductions in the AngularJS 1.3 release. It offers one-time data binding, allowing the developer to reason about the necessity of real-time data being interpolated in the template and elect to opt out of that data binding in order to improve the overall performance of the application.
How to do it…
One-time data binding can be signaled inside the parsed expression at the time of compilation by prepending the expression with ::
, as demonstrated here:
<span ng-show="user.isAuthenticated">{{ ::user.name }}</span>
This will maintain normal...