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>
Comments
Post a Comment