简体   繁体   中英

How to un-select a selected option in md-select multiple (in angularjs)?

This is my code in html

 <md-select ng-model="vm.hostSettings.cohostLists"  value="{{vm.hostSettings.cohostLists}}" multiple="true">
  <md-optgroup >
      <md-option ng-value="host" ng-repeat="host in vm.coHostList" ng-selected="{{ vm.selectedUser.indexOf(host.user.firstName) > -1}}">{{host.user.firstName}}</md-option>
  </md-optgroup>
</md-select>

How to un-select a selected option in md-select multiple (in angularjs) ?

I've got the answer.Change the html code as below

                        <md-select ng-model="vm.hostSettings.cohostLists"
                                   ng-model-options="{trackBy: '$value.id'}" multiple="true">
                            <md-option ng-value="host" ng-repeat="host in vm.coHostList">{{
                                host.user.firstName}}
                            </md-option>
                        </md-select>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM