1

I have this json:

[
{
    "month": "Feb",
    "title": "Title 1",
    "status": "Closed"
},
{
    "month": "Feb",
    "title": "Title 2",
    "status": "Delayed"
},
{
    "month": "Feb",
    "title": "Title 3",
    "status": "Open"
},
{
    "month": "Mar",
    "title": "Title 4",
    "status": "Closed"
}

]

I'm trying to fill a select box with months:

<select id="month" ng-model="monthFilter" ng-options="task.month for task in tasks | filter: monthFilter">
    <option value="">MONTH</option>
</select>

I don't know if I'm doing it in the right way but obviously it returns me a list of all arrays' months: Feb, Feb, Feb, Mar. How can I make angular return me only Feb, Mar?

Some help would be appreciated.

Ramon Vasconcelos
  • 947
  • 3
  • 14
  • 31

1 Answers1

1
ng-options="task.month for task in tasks | unique:'task.month'"

Hope that works for you, or at least leads you in the right direction.

EDIT: Try looking here for what you need: Angular UI ~ UI.Utils Doc

dkiefer
  • 501
  • 5
  • 13
  • It doesn't seem to work, it returns me this error https://docs.angularjs.org/error/$injector/unpr?p0=uniqueFilterProvider – Ramon Vasconcelos Oct 28 '14 at 15:05
  • Play around with it or do some more research. This question has been asked more than once here, which is why it was marked as a duplicate before I even answered it. – dkiefer Oct 28 '14 at 15:25