javascript - 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 api having 2 or more objects. in objects there different. different key values id, name, account etc. need show ids of objects, in select box.
i using ng-repeat in html:
<select ng-model="selectedid" class="form-control"> <option ng-repeat="id in editidoptionsdata" value="{{id}}">{{id}}</option> </select> and response doing :
deal.getiddata($scope.accountdetail.accountusers[0].role, $scope.accountdetail.id) .then(function successcb(data){ $scope.editidoptionsdata=data; }); but in select box getting objects. can tell me how fetch id object in 1 value selected default?
what think you're doing setting whole object option
<select ng-model="selectedid" class="form-control"> <option ng-repeat="id in editidoptionsdata" value="{{id}}">{{id}}</option> </select> the 'id' in code 1 whole object. should is:
<option ng-repeat="id in editidoptionsdata" value="{{id.id}}">{{id.id}}</option> or readability
<option ng-repeat="element in editidoptionsdata" value="{{element.id}}">{{element.id}}</option> edit 1: if want select 1 of option based on condition can use ngselected directive:
ng-selected="<your condition>" in example (if understand correctly need)
<select ng-model="selectedid" class="form-control"> <option ng-selected="selectedid == id.id" ng-repeat="id in editidoptionsdata" value="{{id.id}}">{{id.id}}</option> </select> if that's not looking have more specific in questions.
Comments
Post a Comment