# Unique

### What?

Filters out all duplicate objects items from an array by checking the specified key

Select an attribute to check for uniqueness

    {{items | unique:attribute | json}}

### How?

The filter can take the name of the key to check for uniqueness or set to a non-string truthy value to check the entire object.

    <select ng-model="attribute">
    <option value="">-- No Filter --</option>
    <option>firstName</option>
    <option>lastName</option>
    <option>id</option>
    <option>gender</option>
    </select>
    <pre>{{items | unique:attribute | json}}</pre>

    <script>
    $scope.items = [
    { firstName: 'Dean', lastName: 'Sofer',
    id: 1, gender: 'Male' },
    { firstName: 'Dean', lastName: 'Kuntz',
    id: 2, gender: 'Male' },
    { firstName: 'Peter', lastName: 'Piper',
    id: 3, gender: 'Female' },
    { firstName: 'Peter', lastName: 'Darwin',
    id: 4, gender: 'Male' },
    { firstName: 'Janet', lastName: 'Piper',
    id: 5, gender: 'Female' },
    { firstName: 'Dan', lastName: 'Doyon',
    id: 6, gender: 'Male' },
    { firstName: 'Andy', lastName: 'Joslin',
    id: 1, gender: 'Male' },
    ];
    </script>