0

I have data in this form:

$scope.data = [
{name: 'Giani, Pitampura', _id: '01', city:'Delhi'},
{name: 'Giani, Rajouri', _id: '02', city:'Delhi'}, 
 {name: 'Dominoz, Mayur Vihar ', _id: '03', city:'Delhi'}, 
{name: 'Dominoz, Andheri east', _id: '04', city:'Mumbai'}, 
{name: 'Dominoz, Andheri west', _id: '05', city:'Mumbai'},
{name: 'Pizaa planet, west road', _id: '06', city:'Kolkata'}, 
{name: 'Food panda, Gurgaon', _id: '07', city:'Haryana'}
];

Now, I need to create 2 dropdowns:

  1. City
  2. Restaurant The cities list should be populated with unique city names from this data and depending on the city value selected, second drop down should be populated with restaurant names.

How do I go about this?

Simran Kaur
  • 1,103
  • 5
  • 24
  • 40
  • 1
    Can you post what you have tried so far ? – Sambhav Gore Sep 04 '15 at 14:04
  • I ended up manipulating all together a different structure and I can show that if you would like to. I am still trying with this. I understand I need to take out unique values for city and can do rest of the part I believe but since js has no direct method to do it, I am pretty unsure about performance. It is usually going to be large amount of data to handle so that is the reason that I have posted this question. Least worried about getting the code but need to know the best way to do it – Simran Kaur Sep 04 '15 at 14:08
  • 1
    You can use `unique` filter to show only unique city values in the first dropdown. (This is part of angular-ui if you are using. Or you can write your own unique filter) – Sambhav Gore Sep 04 '15 at 14:10
  • Ahh, My bad. I was looking for it in javascript :) Thanks – Simran Kaur Sep 04 '15 at 14:12
  • See a similar example here - http://stackoverflow.com/questions/15914658/angular-js-how-to-make-ng-repeat-filter-out-duplicate-results – Sambhav Gore Sep 04 '15 at 14:14

0 Answers0