How To Use Ng-repeat To Show All The Values Coming From The Api In Which I Need To Show Only One Key Value From All The Objects?
Through my API I am having two or more objects. In objects there are different. Different key values like id, name, account etc. But I need to show only ids of all the objects, in
Solution 1:
What I think you're doing is setting whole object into option
<selectng-model="selectedid"class="form-control"><optionng-repeat="id in editIdOptionsData"value="{{id}}">{{id}}</option></select>
the 'id' in your code is one whole object. What you should do is:
<optionng-repeat="id in editIdOptionsData"value="{{id.id}}">{{id.id}}</option>
Or just for readability
<optionng-repeat="element in editIdOptionsData"value="{{element.id}}">{{element.id}}</option>
EDIT 1: If you want to select one of the option based on some condition you can use ngSelected directive:
ng-selected="<your condition>"
in your example it will be something like that (if I understand correctly your need)
<selectng-model="selectedid"class="form-control"><optionng-selected="selectedid == id.id"ng-repeat="id in editIdOptionsData"value="{{id.id}}">{{id.id}}</option></select>
If that's not what your looking you have to be more specific in your questions.
Solution 2:
Try something like this:
<select ng-model="selectedid" ng-options="object as object.id in object for editIdOptionsData"class="form-control"> </select>
Post a Comment for "How To Use Ng-repeat To Show All The Values Coming From The Api In Which I Need To Show Only One Key Value From All The Objects?"