Comments (12)
Why can not you just filter your data in the controller itself and then bind it to $scope to be used in ng-repeat?
from angular-dragdrop.
Well, I guess I could, but this is cleaner, and shouldn't this be
possible, since angular has this capability?
On Aug 5, 2013 10:55 AM, "codef0rmer" [email protected] wrote:
Why can not you just filter your data in the controller itself and then
bind it to $scope to be used in ng-repeat?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-22119771
.
from angular-dragdrop.
I'm worried to add more code to do just a small task which can be done outside angular-dragdrop.
from angular-dragdrop.
Sure, but doing this outside of ngRepeat is inefficient, inconvenient, and
circumvents some of the benefits of using angular
On Aug 5, 2013 11:24 AM, "codef0rmer" [email protected] wrote:
I'm worried to add more code to do just a small task which can be done
outside angular-dragdrop.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-22121746
.
from angular-dragdrop.
Oh I think you did not get me. Outside of angular-dragdrop means you can inject the filter in your controller and sort the list there.
Instead of doing:
<li ng-repeat="name in names | orderBy: 'name'">{{name.name}}</li>
You can sort the list in the controller itself:
App.controller('FooCtrl', function($scope, $filter) { $scope.names = $filter('orderBy')($scope.names, 'name'); });
from angular-dragdrop.
No, I got that, but this isn't enough, as when I drag/drop in item, I'll
have to do this again, whereas using ngRepeat with orderBy will handle that
for me. I could listen for changes, but if I have a dynamic number of
lists that I'm using ngRepeat to show, and then using a nested ngRepeat to
show the draggable items(which is exactly what I'm doing) this is far less
than ideal
On Aug 5, 2013 11:39 AM, "codef0rmer" [email protected] wrote:
Oh I think you did not get me. Outside of angular-dragdrop means you can
inject the filter in your controller and sort the list there.Instead of doing:
{{name.name}} You can sort the list in the controller itself:
App.controller('FooCtrl', function($scope, $filter) {
$scope.names = $filter('orderBy')($scope.names, 'name');
});—
Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-22122731
.
from angular-dragdrop.
I agree with @strider820, using basic angular filtering is much more convenient than setting up listeners for every filtered ng-repeat. This isn't a lot of extra code to support such a useful basic feature.
from angular-dragdrop.
Fair enough. It will take me some time to merge the commit as I've to think about other scenarios. Thanks for the PR, @strider820
from angular-dragdrop.
@strider820 : I've gone through your commit and noticed that the code can be less complex instead. Also, its not always the case where ng-repeat bound to the draggable - take a look at the dnd-framework demo in the source. The solution I came up with is to provide the filter option in jqyoui-draggable as well as jqyoui-droppable.
// HTML
<div ng-repeat="item in list2 | orderBy: 'title'" ng-model='list2' jqyoui-droppable>
<div ng-model="list2" jqyoui-draggable="{onFilter:'filterMe'}" >One</div>
</div>
// Controller
App.controller('MyCtrl', function($scope, $filter) {
$scope.filterMe = function(list) {
return $filter('orderBy')(list, 'title');
};
});
Finally in angular-dragdrop.js
- I'll just have to filter out the models. What do you think?
from angular-dragdrop.
I guess that could work. But you're still forcing the user to do something in their controller that angular can do for them, which is still not ideal. But I guess this would be better than nothing.
You're right, though, I think I missed some code that needed to go into mutateDroppable, but my code should have taken into account an ng-repeat filter on the droppable item as well (minus what should have gone into mutateDroppable).
from angular-dragdrop.
I thought a lot on this and could not find any other filters to be suitable in ngRepeat except orderBy, limitTo or any custom filter to order the list.
from angular-dragdrop.
from angular-dragdrop.
Related Issues (20)
- Center Draggable element in DropZone HOT 2
- Hi, HOT 1
- Support for SVG elements
- Suggestion
- Resetting elements to original position?
- drag works but drop doesn't work HOT 1
- Drop cloning the items in container with both dragable and droppable HOT 1
- Draggable not working on <tr>
- dynamically created div is not draggable HOT 1
- How can i get the coordinates of div while dragging HOT 1
- Does not work when compile-time debugging is disabled
- Dragable Control HOT 1
- I am not able to edit text by clicking on it when data-drag ="true", contenteditable="true"
- Drop and add item in Array
- How to use it in ionic project?
- Memory Leak with dynamic dom content
- scrollbar bug in shopping cart demo HOT 1
- onDrop event
- onDrag/onStart not applying stlyle until released
- drag and drop is not working with new jquery/jquery-ui -1.13.2
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-dragdrop.