这是我的代码:
angular.module("App").config(function($stateProvider, $locationProvider, $injector) {
$stateProvider
.state("member", {
url: "/member",
views: {
"" : {
templateUrl: "/js/angular/partials/member/index.html",
controller: 'MemberController'
}
}
});
}).controller(
"MemberController",
["$rootScope", "$scope", "$ocLazyLoad", "$location"],
function ($rootScope, $scope, $ocLazyLoad, $location) {
log("Members controller initialized.");
}
);
我不想直接在视图中定义控制器,因为这会让我创建很多不同的功能,所以我想要一次定义控制器。不过它说:
Error: [ng:areq] Argument 'MemberController' is not a function, got string
我尝试将控制器更改为最高版本,在另一个angular.module("App").controller
定义中,但没有任何作用。我做错了什么?
答案 0 :(得分:2)
尝试更改右方括号的位置]
.controller(
"MemberController",
["$rootScope", "$scope", "$ocLazyLoad", "$location",
function ($rootScope, $scope, $ocLazyLoad, $location) {
log("Members controller initialized.");
}
]);