Skip to content

Include 'with' #29

Closed
Closed

Description

@Guinness4U

Could you consider including a 'with' filter as in this solution: http://stackoverflow.com/questions/14788652/how-to-filter-key-value-with-ng-repeat-in-angularjs?
I use nested objects alot and this would be helpful. Thanks.

Activity

  1. a8m commented on Oct 6, 2014

    @a8m
    Owner

    @Guinness4U , take a look on this example, or see: jsbin:

    angular.module('app', ['angular.filter'])
      .controller('MainCtrl', function($scope) {
      //your example data
      $scope.items = { 
        'A2F0C7':{ secId:'12345', pos:'a20' },
        'C8B3D1':{ pos:'b10' }
      };
      //more advantage example
      $scope.nestedItems = { 
        'A2F0C7':{
          details: { secId:'12345', pos:'a20' }
        },
        'C8B3D1':{
          details: { pos:'a20' }
        },
        'F5B3R1': { secId:'12345', pos:'a20' }
      };
    });
      <b>Example1:</b>
      <p ng-repeat="item in items | toArray: true | pick: 'secId'">
        {{ item.$key }}, {{ item }}
      </p>
    
      <b>Example2:</b>
      <p ng-repeat="item in nestedItems | toArray: true | pick: 'secId || details.secId'">
        {{ item.$key }}, {{ item }}
      </p> 

    let me know what do you think..

  2. Guinness4U commented on Oct 8, 2014

    @Guinness4U
    Author

    Looks great. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions