Understanding Binding Restrictions

I read about bindonce as a way to reduce hours and increase productivity. To better understand the package, I made an example with ng-repeat .

Jsbin here

Without bindonce I get 103 hours, 100 list items + 2 buttons.

Using bindonce , I get 3 time zones, 2 checkers + 1 list fort.

If I understood binonce , it deletes the clock as soon as the binding object is resolved and displayed. So,

How is it possible that when using bindonce changes made to the object are still reflected in the DOM?

+7
angularjs angularjs-directive bindonce
source share
1 answer

The documentation has a hint:

Now this example uses 0 watches per person and renders exactly the same result as the above that uses ng-. *(Angular still uses 1 watcher for ngRepeatWatch)

The key is that Angular still stores the ngRepeat clock, so if the array modifies ngRepeat , the array will be re-mapped and the bindonce function will be bindonce .

I updated your jsbin example here to better illustrate this http://jsbin.com/xugemico/2/edit

Pay attention to the following addition:

 <p> Bindonce: first item: <span bindonce="arr" bo-bind="arr[0]"></span> </p> 

In the above code, bindonce used for the first element of the array without viewing ngRepeat in the game, you will see that the value is not updated according to bindonce inside ngRepeat.

+9
source share

All Articles