Angular filter on the obj

23 views Asked by At

Im trying to set up a search, orderBy, and limit to the list of events in Angular ngRepeat:

self.guides = [
 {name: 'name', 
  events: {
    event: 'event',
    event1: 'event1'
  }},
 {name: 'name1', 
  events: {
    event: 'event',
    event1: 'event1'
  }},
];

and here is html:

<input ng-model="myCtrl.query" type="text" placeholder="Search">

<div ng-repeat="(event, value) in myCtrl.guides track by $index | filter: myCtrl.query | orderBy: 'name' | limitTo: 1">
    <h1>{{value.name}}</h1>
    <div ng-repeat='key in value.events'>
      {{key.event}}
      {{key.event1}}
    </div>
</div>

and at the end non of this works, there is no errors in the console ignores everything typed in the input

1

There are 1 answers

0
Walter Chapilliquen - wZVanG On

Here ng-repeat='key in value.events' You are taking key as direct value, Try:

<div ng-repeat='key in value.events'>
  {{key}}
</div>

//also

<div ng-repeat='(key,val) in value.events'>
  {{val}}
  or
  {{value.events[key]}}
</div>