Rahul Unnikrishnan
Rahul Unnikrishnan

Reputation: 69

How to make a md-radio-button selected by default within md-radio-groups

I have some 3 radio buttons in buttton group which is used for filtering the data now i want to get a button selected by default when page loads

Here is the code

<md-radio-group ng-model="status" aria-label="filter" ng-model="status" name="patient" layout="row">
     <md-radio-button value="">All</md-radio-button>
     <md-radio-button value="active"> Active </md-radio-button>
     <md-radio-button value="inactive">inActive</md-radio-button>
</md-radio-group>

Upvotes: 2

Views: 6656

Answers (1)

Vivek Doshi
Vivek Doshi

Reputation: 58563

First remove multiple ng-model from md-radio-group , it should be there only one time.

Component Side

status = 'active';

Template side :

<md-radio-group [ngModel]="status">

OR

Like this :

<md-radio-button value="active" [checked]='true'> Active </md-radio-button>

Upvotes: 4

Related Questions