外部javascript 方法修改 angularjs 中$rootScope和$scope
阿新 • • 發佈:2019-01-08
【轉載】【轉載】【轉載】http://www.cnblogs.com/wangshuming/p/5569894.html
外部javascript 方法修改 angularjs 中
scope
修改 $rootScope
var $body = angular.element(document.body); // 1
var $rootScope =
root; // 2
apply(function () { // 3
$rootScope.notesconfigs.outpath = path;
});
修改 $scope
var appElement = document.querySelector(’[ng-controller=mainController]’);//獲得繫結controllerdom節點
var
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.
複製程式碼