Reputation:
I am creating a web app in mvc-5
I have taken radio button of material designing. Here is my radio button:
<md-radio-group ng-model="mdgender" ng-change="changeradio()" ng-init="mdgender.Datewise='Datewise'">
<md-radio-button ng-model="mdgender.Datewise" ng-checked="1==1" value="Datewise" class="col-md-2 col-sm-2">Date wise</md-radio-button>
<md-radio-button ng-model="mdgender.CompanyWise" value="CompanyWise" class="col-md-2 col-sm-2">Company Wise</md-radio-button>
</md-radio-group>
I want the 1st radio button to be checked on page load, but I am unable to do this.
1 I tried
ng-checked=true;
2
ng-init="mdgender.Datewise='Datewise'";
but I am still not able to solve this.
What do I need to do if I want my first radio button to be checked on pageload?
Upvotes: 3
Views: 865
Reputation: 2944
You need to set ng-model of <md-radio-group>
<md-radio-group ng-model="mdgender" ng-change="changeradio()" ng-init="mdgender='Datewise'">
Here
ng-model="mdgender"
in md-radio-group has to be initialized to ng-init="mdgender='Datewise'"
Plunker DEMO
Upvotes: 2
Reputation: 1324
Try to add:
ng-class="{'md-checked': your_expression}"
Seems like ng-checked is not working with md-radio-button
Upvotes: 1