如果 angular js 中的其他操作取决于选择哪个单选按钮,如何执行?



我的项目中有两个单选按钮。根据选择的单选按钮,我需要向后端发送命令。我尝试了许多 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>

应始终将值属性传递给每个单选按钮,因为绑定模型仅使用该值进行更新。下面是一个示例。

<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)");
}
};

最新更新