如何取消选择md-select multiple中的选定选项(在angularjs中)?

时间:2016-08-29 11:13:21

标签: html angularjs

这是我在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>

如何在md-select multiple(在angularjs中)中取消选择所选选项?

1 个答案:

答案 0 :(得分:-2)

我已经得到了答案。更改html代码如下

                        <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>