cybergeeeek
cybergeeeek

Reputation: 430

uncheck radio button on button click using angularjs

This simple thing i'm not able to do and me new to angularjs.. I have two radio buttons(suppose named female and male) with same ng-model and 1 reset button.

When i tap reset button i want both radio button to be unchecked.

I tried many things but did not work.

simple example will be good.

thanks

Upvotes: 0

Views: 1354

Answers (1)

georgeawg
georgeawg

Reputation: 48968

<script src="//unpkg.com/angular/angular.js"></script>
<body ng-app>
    <input type="radio" name="sex" ng-model="sex"
           value="male">male<br>
    <input type="radio" name="sex" ng-model="sex"
           value="female">female<br>
    sex={{sex}}<br>
    <button ng-click="sex=null">Reset</button>
</body>

For more information, see AngularJS input type=radio Directive API Reference.

Upvotes: 1

Related Questions