Comments (17)
@djsmith42
quickRepeatList attribute contains a key name for hash storing $watch callbacks. While linking a new directive, we store a reference to $watch callback in that hash using quickRepeatList attribute:
https://github.com/allaud/quick-ng-repeat/blob/master/quick-ng-repeat.js#L126
And the next time we need to refresh our list we don't need to wait for digest cycle (which is usually heavy, moreover it is done synchronously). Instead we can call this callback manually and asynchronously:
https://github.com/allaud/quick-ng-repeat/blob/master/example/js/main.js#L53
This allows us to make a heavy list render without blocking ui (and many more things, redraw some lists eventually for example, without redrawing the whole application).
So, the answer to your questing is - yes, most of the time you should use uniq names for that attribute. But I also can imagine some rare situations, when you need to replace one watcher callback with another.
from quick-ng-repeat.
Why wouldn't you generate unique one yourself if you need it pretty much every time ?
from quick-ng-repeat.
@ojosdegris can you show the line of code you are speaking about?
from quick-ng-repeat.
@allaud I'm talking about quick-repeat-list directive, if it is better to have it every time, why not to generate unique value for it inside main directive ?
from quick-ng-repeat.
@ojosdegris this the the code from html:
<div quick-ng-repeat="item in list" quick-repeat-list="items">
And this is the code from main.js , which contains some lazy-load logic:
https://github.com/allaud/quick-ng-repeat/blob/master/example/js/main.js#L53
_.defer(quickRepeatList.items, $scope.list);
Specifying this name lets us to call from our code directly the list we want to operate with.
from quick-ng-repeat.
Then is there a way to supply this parameter dynamically?
I'm using quick-ng-repeat in a template that is used twice on the same page. Each instance needs a unique quick-repeat-list value, but because this is in a template, I can't supply two different values. If I use a scope variable like this it doesn't work: quick-repeat-list="[[ myQuickRepeatList ]]"
.
I realize that this parameter is necessary to refer to your list in javascript, but if I understand it correctly, the current setup still seems not ideal since it makes the plugin unusable in my case. If there's no way to supply quick-repeat-list dynamically, would it be better to store watch callbacks as an array of objects instead?
from quick-ng-repeat.
Agreed, this doesn't seem like something that the developer should need to set for 99% of cases. The directive should generate its own unique values unless explicitly specified.
from quick-ng-repeat.
@justinmc @leisms accepted, the fix is coming
from quick-ng-repeat.
@justinmc @leisms this addition should do the trick: b5e51ac
from quick-ng-repeat.
I think you mistyped from one copy of the quick-ng-repeat.js file to the other, check out my pull request.
After applying my pull request, this works for my use case. Thanks for the quick fix, I think it's much better like this! Now if you want to updated all instances, you can do something like this:
for (var key in quickRepeatList) {
quickRepeatList[key](mydata);
}
This is really useful when you have multiple instances of quick-ng-repeat operating on the same data, especially when you're unable to assign unique quick-repeat-list parameters like I was.
from quick-ng-repeat.
@justinmc yep, this was my mistake, thanks for contributing. I think, we can close this issue
from quick-ng-repeat.
It may be worth mentioning here that issue #9 addresses some of the use cases mentioned in this thread. The change will give you more flexibility in naming dynamically-generated lists so you can retrieve them later.
from quick-ng-repeat.
@Adarsh456 Your code is missing!
from quick-ng-repeat.
Quick-ng-repeat solved my issue with weird animated floating divs' behavior. Thanks!
http://stackoverflow.com/questions/25020731/racing-condition-with-dom-manipulation-ng-repeat-and-ng-class-animation-in-angu/25023599#25023599
from quick-ng-repeat.
Thank a lot....It get me rid of performance issues in IE8.
from quick-ng-repeat.
I want to repeat the hierarchical data using quick-ng-repeat. How can i do this?
from quick-ng-repeat.
This is going on in: vm.FilteredData = $filter('filter')(vm.data, { CategoryId: vm.currentCategory.id });
All I get is one empty item. What could I be doing wrong here? Is it because of quick-repeat-list?
from quick-ng-repeat.
Related Issues (19)
- Does not work correct for angular resource HOT 2
- orderBy doesn't seems to work HOT 10
- clean example to get started HOT 2
- $digest already in progress (on $rootScope) HOT 3
- Demo page HOT 2
- It looks not work with a matrix HOT 1
- Adding list_id to window scope HOT 1
- Digest cycle error on $rootScope filter HOT 10
- add support for $index HOT 3
- Document the bower package is "quick-ngrepeat" not "quick-ng-repeat" HOT 2
- bump bower version HOT 2
- ng-repeat in ng-repeat HOT 1
- Rowspan with quick-repeat
- Create gh-pages branch for the example HOT 3
- where is items function defined? HOT 2
- Does it support filters and alias? HOT 4
- 5 seconds to 3 seconds HOT 7
- $interpolate quick-repeat-list attribute HOT 1
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 quick-ng-repeat.