#ng-repeat filtering help!

7 messages · Page 1 of 1 (latest)

scenic yew
#

Hello,

How can I do a ng-repeat filtering by a property value of the object I am iterating?

This doesn't seem to work:

<a
  ng-href="/ambitos/{{ambit.id}}"
  class="btn btn-primary"
  ui-sref="ambitos-id({ambitid: ambit.id})"
  ng-repeat="ambit in area.ambits | filter: {ambit.status: 'Publicado'}"
  ng-if="ambit.model === 'S'"
  title="{{ambit.name}}">{{ambit.name}}
</a>
#

I want to filter by ambit.status

quartz wigeon
#

https://docs.angularjs.org/api/ng/filter/filter:

Object: A pattern object can be used to filter specific properties on objects contained by array. For example {name:"M", phone:"1"} predicate will return an array of items which have property name containing "M" and property phone containing "1".

scenic yew
#

Yes I have read some stack overflow posts, but no real clear answer. According to this doc, does this mean I can leave it like:

ng-repeat="ambit in area.ambits | filter: {status: 'Publicado'}"

quartz wigeon
#

Yes.

scenic yew
#

Thank you sir!

scenic yew
#

@quartz wigeon fyi this also works!
ng-repeat="ambit in area.ambits | filter: ambit.status = 'Publicado'"