我的项目中有两个单选按钮。根据选择的单选按钮,我需要向后端发送命令。我尝试了很多ng - ****如果其他操作对我没用。请帮助我同样的
$scope.compareReference = function() {
if($scope.radoreslt is checked){
Factory.send("GetAddonData(CompareBkcXml,$scope.filetxt,File)");
}else{
Factory.send("GetAddonData(CompareBkcXml,$scope.filetxt,All)");
}
};

<div id="collapseTwo" class="panel-collapse collapse" aria-expanded="false">
<div class="box-body">
<div class="input-group">
<div class="form-group">
<label>
<input type="radio" ng-model="radoreslt" name="r1" checked>Compare with File Specific
</label>
<label>
<input type="radio" ng-model="radoreslt" name="r1">Compare All
</label>
</div>
<input type="text" class="form-control" ng-model="filetxt">
<span class="input-group-addon"><input type="File" onchange="copyMe(this)" ></span>
</div>
<br/>
<button class="btn btn-primary btn-sm" ng-click="compareReference()">Compare</button>
</div>
</div>
&#13;
答案 0 :(得分:0)
您应始终将值属性传递给每个单选按钮,因为绑定模型仅使用该值更新。这是一个例子。
<input type="radio" ng-model="radoreslt" name="r1" value="compareWithSpecific">
<input type="radio" ng-model="radoreslt" name="r1" value="compareAll">
<强> JS 强>
$scope.compareReference = function() {
if ($scope.radoreslt == "compareWithSpecific") {
Factory.send("GetAddonData(CompareBkcXml,$scope.filetxt,File)");
} else {
Factory.send("GetAddonData(CompareBkcXml,$scope.filetxt,All)");
}
};