我有一个问题。我无法使用Angular.js选择多个单选按钮。我将在下面解释我的代码。
<div class="input-group bmargindiv1 col-md-12">
<label class="checkbox-inline">
<input type="radio" name="favoriteColors" ng-model="discountPrice" value="true" ng-click="disInclusive();">Discount inclusive
</label>
<label class="checkbox-inline">
<input type="radio" name="favoriteColors" ng-model="discountPrice" value="false" ng-click="disInclusive();">Discount Exclusive
</label>
</div>
<div class="input-group bmargindiv1 col-md-12" ng-show="billdata.uncp.$valid && billdata.discount.$valid && billdata.unsp.$valid && billdata.ulsp.$valid && billdata.quantity.$valid && billdata.prcode.$valid">
<input type="radio" name="favoriteColors" ng-model="isChecked" value="true" ng-required="!isChecked">Add new stock
<input type="radio" name="favoriteColors" ng-model="isChecked" value="false" ng-required="!isChecked">Update stock
</div>
以下是我的控制器端代码。
$scope.disInclusive=function(){
//console.log('hii',$scope.unit_sale_price==null,$scope.discount==null);
if(($scope.unit_sale_price != '' && $scope.unit_sale_price !=null) && ($scope.discount !='' && $scope.discount !=null)){
//console.log('hello');
if($scope.discountPrice=='false'){
var price=(parseInt($scope.discount)/100)*(parseInt($scope.unit_sale_price));
$scope.latest_sale_price=parseInt($scope.unit_sale_price)-price;
}
if($scope.discountPrice=='true'){
$scope.latest_sale_price=$scope.unit_sale_price;
}
}else{
//console.log('hii else');
if($scope.discount =='' || $scope.discount ==null){
alert('Please add the discount');
return;
}
if($scope.unit_sale_price =='' || $scope.unit_sale_price ==null){
alert('Please add the unit sale price');
return;
}
}
}
这里有两组单选按钮,我需要选择其中的一个。我的问题是,当我从第二个集合中选择第二个单选按钮时,第一个单选按钮会消失。我需要从每个集合中选择一个单选按钮。请帮助我。