Ionic and AngularJs: How to filter repeated names in ngRepeat

3

How to filter, with Ionic and AngularJs, repeated names in my ng-repeat ? I've already used ui.filters and unique only works when there are no routing, ie on websites in mobile applications it does not work.

In my controller I tried this:

angular.module('myApp', ['ui.filters'])
       .controller("papaRoca", function($scope, Data, $location) { });

And in my view I put:

<div ng-repeat="Lista in Listas | unique:'nome'">...</div>

Can anyone help me?

    
asked by anonymous 13.07.2016 / 04:25

1 answer

1
app.filter('unique', function() {

  return function (arr, field) {
    var o = {}, i, l = arr.length, r = [];
    for(i=0; i<l;i+=1) {
      o[arr[i][field]] = arr[i];
    }
    for(i in o) {
      r.push(o[i]);
    }
    return r;
  };
})

try this function.

    
15.09.2016 / 14:04