Я хочу использовать мои угловые данные области JS внутри моей диаграммы google или JavaScript My angular JS файла, приведенного ниже
angular.module('reports').controller('ReportInfoCtrl', ['$scope', 'reports', '$rootScope','$location','blockUI',
function ($scope, reports, $rootScope, $location, blockUI) {
$scope.getReportDetail = function () {
blockUI.start();
reports.getReportInformation().then(function (data) {
blockUI.stop();
if (data !== undefined) {
$scope.report_details = data;
}
});
};
}]);
Да, конечно. Вы можете получить доступ к своей переменной видимости контроллера вне вашей угловой.
var controllerElement = document.querySelector('[ng-controller="ReportInfoCtrl"]'); // You can use javascript or Jquery to select the controller div element.
var controllerScope = angular.element(controllerElement).scope(); // Angular provided the interface to access angular scope
var asd = controllerScope.report_details; // Now you can access all scope variable using 'controllerScope'
Обновить
angular.module('reports').controller('ReportInfoCtrl', ['$scope', 'reports', '$rootScope','$location','blockUI',
function ($scope, reports, $rootScope, $location, blockUI) {
$scope.getReportDetail = function () {
blockUI.start();
reports.getReportInformation().then(function (data) {
blockUI.stop();
if (data !== undefined) {
$scope.report_details = data;
}
return data;
});
};
}]);
И в вашем js файле,
var asd = controllerScope.getReportDetail();
Асинхронные манипуляции с областью должны происходить в пределах $scope.apply
должны быть замечены угловыми.
controllerScope
? это пусто?