我想在外部JavaScript函数QCQAIssues()中访问GetQCQAData()函数。GetQCQAData()函数定义在ng-controller内部。我该怎么做? 我尝试了很多方法来解决这个问题,但它们都无效。
function QCQAIssues() {
$('#tblLegend').hide();
createCookie("SelectTab", "QCQA");
$('#tblQCQAIssue tr:gt(0)').remove();
}
var app = angular.module('myModule', []);
app.controller('QCQA', function ($scope, $http) {
//$("[id$='ddlModuleBar']").append('<option value=0>--------All--------</option>');
//$("[id$='ddlSystemBar']").append('<option value=0>--------All--------</option>');
//GetSupportData();
fetchSystemInformation();
fetchModuleSelected();
GetQCQAData();
$scope.setSelected = function () {
// console.log("show", arguments, this);
if ($scope.lastSelected) {
$scope.lastSelected.selected = '';
}
this.selected = 'rowSelect';
$scope.lastSelected = this;
}
$scope.predicate = '-Date';
//$scope.GetQCQAData=function(){
function GetQCQAData() {
blockUI();
$http({
method: 'Get',
url: '/Home/GetQCQAData',
}).success(function (data, status, headers, config) {
$scope.QCQA = data.QCQAData;
var fetchedQCQACountLen = data.QCQACount.length;
if (fetchedQCQACountLen > 0) {
$('#tblQCQAIssue tr:gt(0)').remove();
$('#OpenKeyQ').removeClass('KeyOpen');
$('#OpenKeyQ').addClass('KeyOpenIssue');
$('#lblOpenCountQ').html("");
$('#lblClosedCountQ').html("");
$('#lblInProgressCountQ').html("");
$('#lblOnHoldCountQ').html("");
$('#lblInProgress3DaysCountQ').html("");
var sv = getCookie('SelectTab');
if (sv == 'Support') {
$('#tblLegendQcqa').hide();
$('#tblLegend').show();
}
else if (sv == 'QCQA') {
$('#tblLegendQcqa').show();
$('#tblLegend').hide();
}
for (var i = 0; i < fetchedQCQACountLen; i++) {
if (i == 0)
$('#lblOpenCountQ').html(' Open (' + data.QCQACount[i] + ')');
else if (i == 1)
$('#lblClosedCountQ').html(' Closed Today (' + data.QCQACount[i] + ')');
else if (i == 2)
$('#lblInProgressCountQ').html(' In Progress (' + data.QCQACount[i] + ')');
else if (i == 3)
$('#lblOnHoldCountQ').html(' On Hold (' + data.QCQACount[i] + ')');
else if (i == 4)
$('#lblInProgress3DaysCountQ').html(' Inactive for more than 3 working days (' + data.QCQACount[i] + ')');
}
}
enablePinning: true;
unblockUI();
//$("[id$='ddlModuleBar']").append('<option value=0>--------All--------</option>');
}).error(function (data, status, headers, config) {
unblockUI();
$scope.message = 'Unexpected Error';
});
}
angular.element(elementthathasthescope).scope().GetQCQAData()
并跟随作用域应用来访问该作用域。 - PSL