Jsp中调用AngularJS控制器方法

有时候需要在jsp中调用angularJs控制器中的function或者改变其中的对象,很简单,可以使用下面方式:

xxx.jsp

var $scope = angular.element('#myCtrl').scope();
$scope.$apply(function () {
    $scope.test(); // controller中的方法
});

test.js

var app = angular.module('myApp', []);
app.controller('myCtrl',['$scope','$http',function($scope,$http){
   $scope.test = function(obj){
        //
   }
}

猜你喜欢

转载自blog.csdn.net/huangdi1309/article/details/79541477