ui-select2 icon indicating copy to clipboard operation
ui-select2 copied to clipboard

How to clear selected values in ui-select2

Open salini11 opened this issue 7 years ago • 2 comments

I have something like this

<select  ui-select2="{ allowClear: true}" ng-model="form_user_id" id="source" multiple="multiple">
    <option value="{{row.user_id}}" ng-repeat="row in user_data track by $index">{{row.name}} - {{row.mobile}}</option>
</select>

In some cases I need to clear the selected values. For that I cleared the ng-model form_user_id
$scope.form_user_id = []; When I do that in my code, I can see the array is truncated, but the view still shows the items. How can I clear the view?

salini11 avatar Mar 27 '18 10:03 salini11

I met this problem too, have you found any solutions? @salini11

HalShaw avatar Apr 09 '18 02:04 HalShaw

You can use this code to clear selected. But i don't like.

$scope.form_user_id='';
$('#source').val(['']).trigger('change');

ziqidonglain avatar Dec 04 '19 09:12 ziqidonglain