Angular 1.5 One-Time Binding Notes

We can use Angular’s (1.3+) in-built one-time bindings to gain a performance boost on data which is set once and never changes. The way it works is by removing the watchers ($watch() bindings) on scope bound expressions so when the values are set once they revoke their binding. This reduces the number of watchers registered on the $digest cycle and consequently the number of re-renders on the DOM.

Angular Official Docs: https://docs.angularjs.org/guide/expression#one-time-binding

“One-time expressions will stop recalculating once they are stable, which happens after the first digest…”
This is how you do one-time bindings.


DO:


DO NOT:

Because it blows up.

Additional thoughts around one-time bindings:

  • Only use one-time binding on values which DO NOT change once the page has loaded.
Links:
Sam is a web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and love to share what he learns.

Leave a Reply

Your email address will not be published. Required fields are marked *