我想在我的谷歌图表或 JavaScript 中使用我的 Angular JS 范围数据 下面给出我的 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;
}
});
};
}]);
最佳答案
是的,当然。您可以在 Angular 之外访问 Controller 的范围变量。
var controllerElement = document.querySelector('[ng-controller="ReportInfoCtrl"]'); // You can use javascript or Jquery to select the controller's div element.
var controllerScope = angular.element(controllerElement).scope(); // Angular provided the interface to access angular's 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();
关于javascript - 如何在 JavaScript(Google Chart) 中使用 Angular JS 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33931491/