Giter Club home page Giter Club logo

Comments (12)

codef0rmer avatar codef0rmer commented on August 20, 2024

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.

strider820 avatar strider820 commented on August 20, 2024

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.

codef0rmer avatar codef0rmer commented on August 20, 2024

I'm worried to add more code to do just a small task which can be done outside angular-dragdrop.

from angular-dragdrop.

strider820 avatar strider820 commented on August 20, 2024

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.

codef0rmer avatar codef0rmer commented on August 20, 2024

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.

strider820 avatar strider820 commented on August 20, 2024

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.

    mooyah avatar mooyah commented on August 20, 2024

    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.

    codef0rmer avatar codef0rmer commented on August 20, 2024

    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.

    codef0rmer avatar codef0rmer commented on August 20, 2024

    @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.

    strider820 avatar strider820 commented on August 20, 2024

    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.

    codef0rmer avatar codef0rmer commented on August 20, 2024

    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.

    codef0rmer avatar codef0rmer commented on August 20, 2024

    Fixed as #39 - 62420f5

    from angular-dragdrop.

    Related Issues (20)

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo 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.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.