这是我在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中)中取消选择所选选项?
答案 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>