angular.js - ng-model如何绑定二选一的单选项框?
漂亮男人
漂亮男人 2017-05-15 17:08:59
0
3
565

漂亮男人
漂亮男人

reply all(3)
阿神
<label>
    <input type="radio" ng-model="sex" value="male">
    <span>男</span>
</label>
<label>
    <input type="radio" ng-model="sex" value="female">
    <span>女</span>
</label>
{{sex}}

As for the name attribute, I tried it. As long as the values ​​bound to ng-model are the same, they are considered to be a group

左手右手慢动作

Use ng-checked

<label class="">
    <input type="radio" ng-checked="option==1" ng-click="option=1">
    <span>a</span>
</label>
<label class="">
    <input type="radio" ng-checked="option==2" ng-click="option=2">
    <span>b</span>
</label>
習慣沉默

The radio button box lacks the name attribute. How does the browser know that it is a group of radio button boxes? How does Angular know that it is a group of radio button boxes?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template