我想在变量中设置选中的radiobutton
的值。但我无法得到它。下面是我尝试过的代码
master.controller('FiberLead_Filter', function($scope, $http, NEIQC_Service, Scopes, $rootScope) {
var rdSelectMP = $scope.MPSelect; // here I am getting undefined
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.25/angular.min.js"></script>
<div class="rightFilter" ng-controller="FiberLead_Filter as Filter" id="FiberLead_Filter">
<div class="pdfDownload customeRadioWrap">
<div class="customeRadio">
<input type="radio" id="btnCurrentMP" name="radio-group" ng-model="MPSelect" ng-value="Current">
<label for="btnCurrentMP">Current MP</label>
</div>
<div class="customeRadio">
<input type="radio" id="btnAllMP" name="radio-group" ng-model="MPSelect" ng-value="All">
<label for="btnAllMP">All MP</label>
</div>
<button class="btn btn-default customBtn" ng-click="DownloadExcelReport()"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> Download</button>
</div>
</div>
让我知道我的代码出了什么问题UNDEFINED
答案 0 :(得分:2)
这是因为data = [(1,2,3), (1,5,3), (1,8,3), (1,10,3), (1,16,3), (1,17,3)]
MAXIMUM_ANGLE = 5
def angles_within_range(x, y):
return abs(x[1] - y[1]) <= MAXIMUM_ANGLE
def first_angle_break_index():
for i in range(len(data) - 1):
if not angles_within_range(data[i], data[i+1]):
return i+1
def valid_angles_list():
return data[:first_angle_break_index()]
print(valid_angles_list())
正在寻找“全部” ng-value
变量,但可能没有任何变量。
如果期望值是字符串,请使用$scope
,或者使用'All'
。
在下面的工作小提琴中,单击“下载”按钮以记录当前值(首先选择一个值)。
value
angular.module('app', []);
angular.module('app').controller('FiberLead_Filter', function($scope, $http, $rootScope) {
$scope.DownloadExcelReport = function(){
console.log($scope.MPSelect);
}
}
);