Angular 1.X Filter by Properties

Filtering By Nest Property
  $scope.list = [
    { 'Name': 'A',
      'Manager': {
        'Name': 'X'
      }
    },
    { 'Name': 'B',
      'Manager': {
        'Name': 'X'
      }
    },
    { 'Name': 'C',
      'Manager': {
        'Name': 'Y'
      }
    }];

    <ul>
      <li ng-repeat="e in list | filter: {Manager: {Name: filter.key}}">
        {{e.Name}}  (Manager: {{e.Manager.Name}})
      </li>
    </ul>

Filter not equals

<li class="list-group-item"
    ng-repeat="question in Questions | filter:{ Id: '!-1'}">
    <div href="#" editable-text="question.Text">{{question.Text}}</div>
</li>

How to get key of the object? (not in the view)

The first parameter to the iterator in forEach is the value and second is the key of the object.
angular.forEach(objectToIterate, function(value, key) {
    /* do something for all key: value pairs */
});
In your example, the outer forEach is actually:
angular.forEach($scope.filters, function(filterObj , filterKey)
Example of GroupBy and Unique

<tr class="ng-cloak" ng-repeat="(key, value) in bl.notelist | groupBy: 'email'">
     <td><span class="ng-cloak" ng-bind="value[0].email"></span></td>
     <td ng-repeat="player in value | unique:'appName'">
         <label class="ng-cloak switch" title="{{player.appName}}">
             <input type="checkbox" ng-checked="player.hasAccess" ng-disabled="!player.canModify">
         </label>
      </td>
 </tr>


Comments

Popular posts from this blog

Ng-repeat: Order a List Vertically rather Horizontal

HTML5 Audio doesn't Autoplay for Chrome on Android

NPOI Does Not Support CSV