标签:
var $body = angular.element(document.body); // 1 var $rootScope = $body.scope().$root; // 2 $rootScope.$apply(function () { // 3 $rootScope.notesconfigs.outpath = path; });
var appElement = document.querySelector(‘[ng-controller=mainController]‘);//获得绑定controllerdom节点 var $scope = angular.element(appElement).scope(); //获得$scope对象 $scope.$apply();//刷新数据
//获取当前元素的$socpe: angular.element(domElement).scope() to get the current scope for the element //获取当前app的injector: angular.element(domElement).injector() to get the current app injector
//获取当前元素的controller: angular.element(domElement).controller() to get a hold of the ng-controller instance.
外部javascript 方法修改 angularjs 中$rootScope和$scope
标签:
原文地址:http://www.cnblogs.com/wangshuming/p/5569894.html