ng-selected not working with ng-repeat,in inspect element i can see ng-selected= true and there is selected attribute on option element.my code is as follows and output screenshot is also given below.
<div class="row">
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
<label for="">{{diamond.category_id}}</label>
</div>
<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
<select ng-model="diamond.category_id" class="form-control">
<option ng-selected="{{diamond.category_id == category.id}}"
value="{{category.id}}"
ng-repeat="category in categoryData"
>{{category.id}}</option>
</select>
</div>
Output Link : http://prntscr.com/bfcdwa
Your code should be like this:
<select class="form-control" ng-options="item.id for item in categoryData track by item"
ng-model="diamond.category_id">
</select>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/164161.html