javascript - Angular ui multiselect binding only desired property -
i'm using angularjs ui select , want select more 1 items.my code this
$scope.user.selectedcategories $scope.categories= [ { value: 'reading', name: 'reading books',id : 4 }, { value: 'sports', name: 'physical activity',id : 9 }, { value: 'movies', name: 'entertainment',id : 7 }, { value: 'video games', name: 'passion',id : 11 } ]; <div class="input-group"> <ui-select multiple ng-model="user.selectedcategories" theme="bootstrap" sortable="true" close-on-select="false" style="width: 350px;"> <ui-select-match placeholder="select categories...">{{$item.value}}</ui-select-match> <ui-select-choices repeat="category in categories"> {{category.value}} </ui-select-choices> </div>
right selectedcategories contain whole object selected want select id property of selected object. desired result
selectedcategories = [4,9,11]
but
selectedcategories = [{value:'reading,name:'reading book',id:4}, {value:'movies',name:'entertainment',id:7}]
use like
<ui-select-choices repeat="category.id category in categories">{{category.value}} </ui-select-choices>
Comments
Post a Comment