I am pushing keys to one array and I am iterating it to get options in dropdown.Creating a (key,value) pair, keys in array and options are same. When we change the option in dropdown, the corresponding value should be rendered in HTML.
Here is the code:
$scope.viewItemKeys = [pencils, pens, books];
$scope.viewItemObj = {
"pencils": {
"0": {},
"1": {},
"2": {}
},
"pens": {
"0": {},
"1": {},
"2": {},
"3": {},
"4": {}
},
"5": {},
"6": {},
"7": {}
},
"books": {
"0": {},
"1": {},
"2": {},
"3": {},
"4": {}
}
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<select id="selId" ng-options="key as value for (key , value) in viewItemkeys" ng-model="selectedItem" ng-change='onItemChange()'></select>
please help me out if I select pens with respect to key (i.e 1 to 7 , inside pens) I need to render {} value