Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

How to clear selected values in ui-select2 #315

Open
salini11 opened this issue Mar 27, 2018 · 2 comments
Open

How to clear selected values in ui-select2 #315

salini11 opened this issue Mar 27, 2018 · 2 comments

Comments

@salini11
Copy link

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?

@HalShaw
Copy link

HalShaw commented Apr 9, 2018

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

@ziqidonglain
Copy link

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

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants