Angular js找不到控制器?

Bru*_*yne 4 jquery angularjs

我使用的是角度js,我在两个不同的jsp文件中编写了代码.显示了两个不同的视图.如果我渲染单个视图它工作正常.但如果我在同一页面上渲染两个视图我得到此错误

Error: Argument 'UserCtrl' is not a function, got undefined

jsp中的js代码片段如下.

在我的第一个jsp文件中

// Bootstrap the Application
var App = angular.module('module', []);
// Set up a controller and define a model
App.controller('UserCtrl', function($scope) {
    $scope.user = {};
    jQuery.get("<c:url value='${someUrl}'/>",
            function(data) {
            angular.element('#user_detail').scope().user = data;
            angular.element('#user_detail').scope().$apply();
}, "json");
});
Run Code Online (Sandbox Code Playgroud)

在第二个是

// Bootstrap the Application
var App = angular.module('module', []);

// Set up a controller and define a model
App.controller('ProfileCtrl', function($scope) {
    $scope.profile = {};
    jQuery.get("<c:url value='${someUrl}'/>",
            function(data) {
            angular.element('#profile').scope().profile = data;
            angular.element('#profile').scope().$apply();
}, "json");
});
Run Code Online (Sandbox Code Playgroud)

我尝试给模块提供不同的名称,但这对我来说也没有用.非常感谢.谢谢 !

Bru*_*yne 6

搞定了.这是由于ng-app变量,我已经将它绑定在两个jsp页面上.所以现在我将它绑定到主体包装器中用于两个jsp的.