Comments (2)
+1
from angular-underscore.
The cause is that Angular's digest loop evaluates expressions at least twice, to check if their output is stable. It clearly isn't in the case of shuffle
, but other functions with non-deterministic return values, e.g. pairs()
, will also cause Angular to get stuck.
The simple solution is to move any expressions with (intermediate, in the case of filters,) non-deterministic return values to your controller (i.e. out of the template). The workaround for this module that comes to mind is to sort the output of non-deterministic functions that are especially useful in templates (such as pairs()
). It incurs a bit of overhead, and will be a less clean mapping to underscore, but it will make this module more usable. Currently, I end up shadowing sorted versions of these functions in my controllers.
It would be nice if Angular could take the entire expression into account (i.e. plus filters), so that this issue would not be caused by expressions that sort their output with filters. Perhaps someone would like to upstream this issue there.
EDIT: the workaround isn't as simple as I stated above. For users of this module, ngRepeat
's track by
clause may help. A true solution will likely involved modified $watch
calls.
from angular-underscore.
Related Issues (20)
- How to use it HOT 2
- What license is the angular-underscore project released under? HOT 1
- how to use the filter filter HOT 1
- map as a filter? HOT 1
- load into controller? HOT 9
- Shiv for "sortedIndex"
- Newly introduced methods 'indexBy' and 'sample' HOT 1
- Uncaught ReferenceError: _ is not defined HOT 2
- Gem? HOT 5
- Make _.delay(), _.throttle(), and _.debounce() karma friendly HOT 3
- Problem with isolated scope HOT 2
- Registering filters 3 times HOT 1
- Underscore is undefined if I use inside a Directive $scope._
- groupBy filter error HOT 3
- More examples? HOT 1
- Sorry but... HOT 1
- property predicate
- Error on minify HOT 1
- Consider a bower package? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-underscore.