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

How to clear selected values in ui-select2 #315

Open
@salini11

Description

@salini11

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?

Activity

HalShaw

HalShaw commented on Apr 9, 2018

@HalShaw

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

ziqidonglain

ziqidonglain commented on Dec 4, 2019

@ziqidonglain

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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      How to clear selected values in ui-select2 · Issue #315 · angular-ui/ui-select2