Skip to content
Advertisement

AngularJS – Display the list of data based on the selected value

Any help appreciated. I have a JSON data with format like this

{ state1: [ member1, member2], state2: [ member,member4…], … }

And there is a dropdown which shows the list of states on the JSON data. Based on the selected state I need to display the corresponding list of member on the table.

JavaScript
JavaScript

Based on the selected state I need to display the list of member in the table with dynamic binding.

Plunker link click here

Advertisement

Answer

It’s been a while since I did something in Angular JS for the last time 🙂

In your Plunker example, there ist already:

JavaScript

but you are missing the implementation.

I would suggest the following approach:

JavaScript

where $scope.selectedState is a scope variable holding the selected state value, ex. “MN” and $scope.selectedMembers contains the array with the corresponding state members.

The last thing you should do is implement the ng-repeat loop on the member table.

Edit: https://plnkr.co/edit/BjFark20dScLGUm2

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement