1
Using Asp.Net MVC 5 with Angularjs want a input radio
come checked by default.
According to the link:
How to select a radio button by default?
Assign an initial value to radio button as checked
Just use this:
<label class="btn btn-default">
<input type="radio" ng-model="ViewBag.Imposto.calcular" value="false">
Não
</label>
<label class="btn btn-default">
<input type="radio" ng-model="ViewBag.Imposto.calcular" value="true" checked="checked">
Sim
</label>
But it’s not working, how to fix it?
Edited
How can be seen in the image, even using the above code the option is not checked.
It works for me... (https://jsfiddle.net/opo1udff/). What you say is not working?
– Sergio
My jsFiddle ( above ) works in your browser?
– Sergio
@Sergio I removed the reference of Angulajs
ng-model="ViewBag.Imposto.calcular"
and it worked. Now I’m even more confused! kkk– Jothaz
Then use
ng-checked="true"
, works?– Sergio
@Sergio killed the riddle! That’s right. I was looking for something like this and I didn’t find it. Elaborate an answer so I can mark it as correct. And thank you so much for your help.
– Jothaz