Radio Input with default value

Asked

Viewed 529 times

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.

inserir a descrição da imagem aqui

  • It works for me... (https://jsfiddle.net/opo1udff/). What you say is not working?

  • My jsFiddle ( above ) works in your browser?

  • @Sergio I removed the reference of Angulajs ng-model="ViewBag.Imposto.calcular" and it worked. Now I’m even more confused! kkk

  • Then use ng-checked="true", works?

  • 1

    @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.

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.