kennechu
kennechu

Reputation: 1422

Set value to radio button after click on button using angular model

I have a set of radio buttons that when I click them they show different content.

<div class="radio" ng-init="topRadios()">
 <input type="radio" ng-model="topTable" value="topCategory" ng-change="updateTotals('topCategory')">TY  30 Categories</label>
 <input type="radio" ng-model="topTable" value="topSupplier" ng-change="updateTotals('topSupplier')">TY Top 10 Suppliers</label>
 <input type="radio" ng-model="topTable" value="topBrand" ng-change="updateTotals('topBrand')">TY Top 10 Brands</label>

</div>

And I have a button to apply some filters to the information that is displayed depending o the radio button selection.

 <button class="goButton btn btn-xs" ng-class="css" ng-click="go()" ng-disabled="isClicked"> Apply </button>

When I click on the third button to see that info for example and then the Apply button with some filters the page refresh and what I want is that when the info and radio buttons displayed the first radio button is selected.

Can anyone help me please?

Upvotes: 0

Views: 614

Answers (1)

paul trone
paul trone

Reputation: 702

sounds like what you want to do is set an initial value for your radio input's ng-model in your controller:

$scope.topTable = 'topCategory';

you probably also want to reset the input's value in your go function after you apply your filtering with that same code snippet.

Upvotes: 1

Related Questions