0

I am trying to create cascading dropdowns with angular js and nested json.

This is my json:

'ListItems':[ {
               'CountryName':'India',
                  'states': [{
                     'stateName':'Maharashtra',
                         'cities': 
                           [{'cityName':'Pune'}, 
                            {'cityName':'Mumbai'}, 
                            {'cityName':'Nagpur'},
                            {'cityName': 'Akola'}
                           ]},
                       {
                     'stateName':'Madhya Pradesh',
                         'cities': 
                           [{'cityName':'Indore'}, 
                            {'cityName':'Bhopal'}, 
                            {'cityName':'Jabalpur'}
                           ]} 
                      ]},
                 {
               'CountryName':'USA',
                  'states': [{
                     'stateName':'Alabama',
                         'cities': 
                           [{'cityName':'Montgomery'}, 
                            {'cityName':'Birmingham'}
                           ]},
                       {
                     'stateName':'California',
                         'cities': 
                           [{'cityName':'Los-Angeles'}, 
                            {'cityName':'San-Francisco'}
                           ]} 
                      ]}

There are two countries. Each country includes states and each state includes cities.

Tuvia Khusid
  • 792
  • 5
  • 15
  • 31
  • If this turns out to not be a duplicate, it should still be closed because your question doesn't show any effort to accomplish this yourself. – m59 Mar 04 '15 at 20:54
  • Not even clear what intended results are, I interpret cascading dropdown as ` – charlietfl Mar 04 '15 at 21:18

1 Answers1

0

Use ng-repeat to parse the elements

    <ul>
      <li ng-repeat="item in ListItems">
        {{item}}
        <ul>
            <li ng-repeat="state in item" >{{state.stateName}}</li>
            ... etc
         </ul>
      </li>
   </ul>
Cristi Marian
  • 443
  • 8
  • 18