[英]How to do radio buttons in Angular
This is my code. 这是我的代码。 When I submit switchColors, the server returns undefined for it.
当我提交switchColors时,服务器为其返回未定义。 How is this wrong?
这怎么了
Also how should I initiate $scope.swichColors in my controller? 另外,如何在控制器中启动$ scope.swichColors? Currently I have $scope.switchColors = '';
目前我有$ scope.switchColors ='';
<label class="radio-inline">
<input type="radio" ng-model="$parent.switchColors" value = "yes" >Yes</input>
</label>
<label class="radio-inline">
<input type= "radio" ng-model = "$parent.switchColors" value = "no" >No</input>
</label>
Try using ng-value instead of value 尝试使用ng-value代替value
<label class="radio-inline">
<input type="radio" ng-model="$parent.switchColors" ng-value = "yes" >Yes</input>
</label>
<label class="radio-inline">
<input type= "radio" ng-model = "$parent.switchColors" ng-value = "no" >No</input>
</label>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.