sag Surya
sag Surya

Reputation: 199

clear selected option by button event in angular js

I have select box and have default value is text "please select one", I need solution while if any other option is selected (eq. abc) and user need to clear what he has selected(important is getting default value selected again) with button("Clear and go Next") event.

http://plnkr.co/edit/HIOOHBHaibHmDtiLdGfh?p=preview

<select ng-model="item" ng-options="item.name for item in options"
    ng-change="doSomething()">
    <option value="">Please select one</option>
</select>

Upvotes: 1

Views: 4940

Answers (1)

Blunderfest
Blunderfest

Reputation: 1854

I'm not entirely sure what you're asking, but if you need to clear the selected value, you can do something as simple as:

HTML

<button ng-click="reset()">Clear and move Next</button>

JS

$scope.reset = function() {
  $scope.item = "";
}

Plunk

Upvotes: 3

Related Questions