JavaScript的function获取AngularJS的$scope对象

来源:互联网 发布:资海网络集团 编辑:程序博客网 时间:2024/06/09 00:07

AngularJS声明controller

app.controller('businessCtrl', function($scope, $http) {    ......    ......});

JavaScript的function获取AngularJS的$scope对象

var appElement = document.querySelector("[ng-controller=businessCtrl]");var $scope = angular.element(appElement).scope(); $scope.title = "";......//使用$scope进行所需要的处理......//需要的处理完成后加入这一行,使生效。$scope.$apply();
原创粉丝点击