html - how to disable previously selected select options displayed using bootstrap selectpicker and ng-options -


i have multi select dropdown. need when user lands on page, need restrict him modify previous selections, disable options inside dropdown. here html -

<div>     <select multiple class="form-control selectpicker" ng-model="selectednames" data-live-search="true" ng-options="opt.name opt in availablenames track opt.id" ng-change="onnamechange()"> </select> </div> 

tried suggestions link - http://silviomoreto.github.io/bootstrap-select/

but if add option tag manually when using ng-options, doesn't displayed. tried using ng-repeat rather ng-options ng-repeat dropdown stopped showing tick-marks against selected values & default displayed - "no values selected", though model still had them.

any pointers how achieve without resorting jquery ?

thanks anup

use disable when syntax in ngoptions. refer ngoptions docs more details. add key in ngoptions indicate if field selected user eg. prevselected: true , tell ngoptions disable option when key set/exists.

<select ng-model="mycolor" ng-options="color.name disable when color.prevselected color in colors"></select> 

example on plnkr


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -