如何在JavaScript(谷歌图表)中使用Angular JS数据
How can I use Angular JS data inside JavaScript(Google Chart)?
我想在谷歌图表或JavaScript中使用我的角度JS范围数据下面给出了我的角度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'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();
异步作用域操作必须发生在$scope.apply
内才能被angular注意到。
相关文章:
- $http中的Angular 1数据绑定承诺不起作用
- 为什么针对工厂的Angular数据绑定只适用于函数
- 从 Angular 数据工厂中的 HTTP POST 请求接收未定义的结果
- 修复Angular数据表中的头插件不起作用
- 使用Angular数据绑定动态舍入总和
- 使用ngSanitize希望添加带有Angular数据绑定代码的jQuery onClick()
- Angular数据没有在TAB加载时加载
- 如何创建一个使用ng-model的angular数据提取器指令
- 如何使用angular数据绑定将一个复选框绑定到一个select disabled属性
- 如何显示 或者angular数据中的任何原始HTML
- 可排序的Angular数据表——可排序的表在第一次加载时呈现良好,但在后续过滤器中不产生记录
- 用angular数据从php创建word/pdf文件
- 在不可绑定元素中使用angular数据绑定和指令
- 指令模板内的Angular数据绑定
- Angular数据问题——不知道如何排除
- Angular数据对象键重命名
- Angular数据没有绑定
- Angular数据绑定没有更新正确的模型范围
- 如何设置"data-title"& lt; td>不用重复使用angular数据表
- 带有延迟渲染的Angular数据表