我试图让工作成为一项简单的任务,但不幸的是,我试图通过单击按钮来检查输入 radio 。每个输入单选按钮作为其按钮。你如何以 Angular 方式实现这一点?
<button class="btn btn-primary">
<input type="radio" ng-model="color" value="1">
</button>
<button class="btn btn-primary">
<input type="radio" ng-model="color" value="2">
</button>
<button class="btn btn-primary">
<input type="radio" ng-model="color" value="3">
</button>
你怎么看我把输入放在元素按钮里面了,如果你有不同的想法请纠正我。
最佳答案
将关联的 ng-model
设置为等于您要选择的 radio 的值
:
<button class="btn btn-primary" ng-click="color = 1">
<input type="radio" name="radioGroup" ng-model="color" value="1">
</button>
关于javascript - 如何从按钮检查输入单选 - AngularJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27256637/