3gwebtrain 3gwebtrain - 1 year ago 137
AngularJS Question

'ng-repeat' How to get the `unique` values

Using an array, I am trying to filter and show the

information in the list. For that I use the

But I am getting error.

Here is my try ( I am filtering by

<li ng-repeat="project in projectNames |
unique: 'SubProjectName' ">{{project.SubProjectName}}</li>

But I am getting an error.

Live Demo

Answer Source

AngularJS doesn't include a unique filter by default. You can use the one from angular-filter. Just include the JavaScript

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.8/angular-filter.min.js"></script>

and include the dependeny in your app:

var app = angular.module('myApp', ['angular.filter']);

Your code should work right away! I edited your Plunker so it works.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download