繁体   English   中英

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

[英]How to perform if else operation in angular js depends on which radio button is selected?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM