论证' mmmController'不是一个函数,得到了字符串

时间:2016-03-31 16:04:22

标签: angularjs

标题中列出的错误让我发疯。棱角为何如此挑剔?我的语法有什么问题?我试图定义一个控制器&子控制器,带路径。

plunker is here

// Declare app level module which depends on filters, and services
var mmm = angular.module('mdp',['ngRoute', 'mmm.controllers']);

mmm.config(['$routeProvider','$locationProvider','$compileProvider','$httpProvider', function($routeProvider, $locationProvider,$compileProvider,$httpProvider) {
        $routeProvider
            .when('/', {
                redirectTo: '/commission',
                controller: 'mmmController'
            })
            .when('/commission', {
                templateUrl: 'form.html',
                controller: 'commCtlr'
            })
            .otherwise({
                redirectTo: '/commission'
            });
        $compileProvider.debugInfoEnabled(false);
        $httpProvider.useApplyAsync(true);
    }])


angular.module('mmm.controllers',[]);

var mmmControllers = angular.module('mmm.controllers');

mmmControllers.controller('mmmController', ["$scope","$rootScope","$http","$location","$route","$log"],function ($scope,$rootScope, $http,$location,$route,$log) {


});

mdpControllers.controller('commCtlr',["$scope"], function($scope) {

});

1 个答案:

答案 0 :(得分:5)

您的控制器注册错误,]位置错误。

mmmControllers.controller('mmmController', ["$scope","$rootScope","$http","$location","$route","$log",
  function ($scope,$rootScope, $http,$location,$route,$log) {


}]);

mdpControllers.controller('commCtlr',["$scope", 
  function($scope) {

}]);