Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat(ngBindOnce) && feat{ngRepeatOnce} Bind to the DOM once with no watchers #5408

Closed
rhettl opened this issue Dec 14, 2013 · 99 comments
Closed

Comments

@rhettl
Copy link

rhettl commented Dec 14, 2013

This feature should include:

  • ngBindOnce
  • ngBindTemplateOnce
  • ngRepeatOnce

This feature would allow a developer to:

  • bind to the DOM one time
  • Reduce the number of watchers on e the page, Esp in situations of nested repeaters

It is for data that:

  • doesn't need to be dynamic
  • is loaded once and forgotten
  • cannot be loaded from the server side code
@Narretz
Copy link
Contributor

Narretz commented Dec 15, 2013

+1

@Narretz
Copy link
Contributor

Narretz commented Dec 15, 2013

or, alternatively, a way to suspend and re-enable watches.

@kennethlynne
Copy link
Contributor

+1

2 similar comments
@manland
Copy link

manland commented Dec 15, 2013

+1

@erwinmombay
Copy link

+1

@rhettl
Copy link
Author

rhettl commented Dec 16, 2013

I have been trying to figure out how to add labels after creating an issue.
Since I cannot figure out how, could a moderator possibly add labels to this?

Thank you greatly!

@lord2800
Copy link

+1

@ghost ghost assigned IgorMinar Dec 20, 2013
@scottmas
Copy link

+1

7 similar comments
@cburgdorf
Copy link
Contributor

+1

@sebholstein
Copy link
Contributor

+1

@CMRahman
Copy link

+1

@nicolacity
Copy link

+1

@adzialocha
Copy link

+1

@panrafal
Copy link

+1

@red-0ne
Copy link

red-0ne commented Dec 21, 2013

+1

@red-0ne
Copy link

red-0ne commented Dec 21, 2013

the enable/disable variant could be great

@melnikov77
Copy link

+1

6 similar comments
@CWSpear
Copy link
Contributor

CWSpear commented Dec 22, 2013

+1

@macl
Copy link

macl commented Dec 23, 2013

+1

@dpiatek
Copy link

dpiatek commented Dec 23, 2013

+1

@sukei
Copy link

sukei commented Dec 23, 2013

+1

@dehru
Copy link

dehru commented Dec 23, 2013

+1

@runxc1
Copy link

runxc1 commented Dec 23, 2013

+1

@rhettl
Copy link
Author

rhettl commented Dec 24, 2013

While Disable/Enable might be nice, I don't think it is necessary. It would be easy enough to wrap the DOM element in an ngSwitch or ngIf to deal with the on/off. Same with nested repeats -- if the first ngRepeat is a normal one and the nested ngRepeats are bindOnce, one can have static content that still changes when the program tells it.

In short, I think that it may be nice to have the enable/disable feature, but if it is easier to just have an ngBindOnce without the enable/disable feature, then don't worry about it and possibly add it in the future if it is needed.

@uglow
Copy link

uglow commented Dec 24, 2013

+1

4 similar comments
@warnerandy
Copy link

+1

@guybedo
Copy link

guybedo commented Dec 24, 2013

+1

@mofas
Copy link

mofas commented Dec 24, 2013

+1

@ghost
Copy link

ghost commented Dec 27, 2013

+1

@ohana54
Copy link

ohana54 commented Jan 14, 2014

+1

5 similar comments
@Pierrebleroux
Copy link

+1

@pawelszymanski
Copy link

+1

@IlanFrumer
Copy link

+1

@RobertSasak
Copy link

+1

@mb-dev
Copy link

mb-dev commented Feb 4, 2014

+1

@matjaz
Copy link

matjaz commented Feb 5, 2014

a way to suspend and re-enable watches would be a great addition to this. for example stock ticker with push data.
templates can have complex layout so using ngSwitch would mean a lot of duplication.

@MichielDeMey
Copy link

+1

I'd like to see this in Angular as well. I'm currently using Pasvaz's Bindonce and it works perfectly.

@ghost
Copy link

ghost commented Feb 9, 2014

We currently use bindonce and this: http://blog.scalyr.com/2013/10/31/angularjs-1200ms-to-35ms/
Its available at https://github.com/scalyr/angular

joshkurz pushed a commit to joshkurz/angular.js that referenced this issue Feb 17, 2014
joshkurz pushed a commit to joshkurz/angular.js that referenced this issue Feb 17, 2014
…ngular#5408

Signed-off-by: Josh Kurz <josh.kurz@turner.com>

fix(ngBindOnceDirsSpec.js): testing everything

Signed-off-by: Josh Kurz <josh.kurz@turner.com>
@mwilc0x
Copy link

mwilc0x commented Feb 19, 2014

+1

@ProLoser
Copy link
Contributor

Please check out #6354 for a better alternative proposal to bind-once

joshkurz pushed a commit to joshkurz/angular.js that referenced this issue Apr 3, 2014
…ngular#5408

Signed-off-by: Josh Kurz <josh.kurz@turner.com>

fix(ngBindOnceDirsSpec.js): testing everything

Signed-off-by: Josh Kurz <josh.kurz@turner.com>
@gautelo
Copy link

gautelo commented Apr 12, 2014

Indeed, please do check out #6354, as @ProLoser suggests. It would give us some simple syntax to solve this, and more than this, instead of a series of additional directives.

@HeberLZ
Copy link
Contributor

HeberLZ commented Apr 27, 2014

+1
Please implement this inside angular core! It would become a must use in many applications

@Dbuggerx
Copy link

+1

1 similar comment
@epegzz
Copy link

epegzz commented Apr 28, 2014

+1

@MaxShv
Copy link

MaxShv commented May 21, 2014

+1

RichardLitt pushed a commit to RichardLitt/angular.js that referenced this issue May 24, 2014
Expressions that start with `::` will be binded once. The rule
that binding follows is that the binding will take the first
not-undefined value at the end of a $digest cycle.

Watchers from $watch, $watchCollection and $watchGroup will
automatically stop watching when the expression(s) are bind-once
and fulfill.

Watchers from text and attributes interpolations will
automatically stop watching when the expressions are fulfill.

All directives that use $parse for expressions will automatically
work with bind-once expressions. E.g.

<div ng-bind="::foo"></div>
<li ng-repeat="item in ::items">{{::item.name}};</li>

Paired with: Caitlin and Igor
Design doc: https://docs.google.com/document/d/1fTqaaQYD2QE1rz-OywvRKFSpZirbWUPsnfaZaMq8fWI/edit#
Closes angular#7486
Closes angular#5408
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.