Angularjs angular.js模块化控制器“;“未定义”;使用$routeParams时

Angularjs angular.js模块化控制器“;“未定义”;使用$routeParams时,angularjs,Angularjs,以下内容在控制台中返回错误“ReferenceError:ThingCtrl未定义” 但是,当控制器的定义如下时,它可以正常工作: function ThingCtrl($scope, $routeParams) { $scope.thing = [ { 'title':'first thing', 'first':'one', 'second': 'two', 'third': 'three' }

以下内容在控制台中返回错误“ReferenceError:ThingCtrl未定义”

但是,当控制器的定义如下时,它可以正常工作:

function ThingCtrl($scope, $routeParams) {
        $scope.thing = [
    {
        'title':'first thing',
        'first':'one',
        'second': 'two',
        'third': 'three'
    }
  ]
};

为什么不能使用模块化语法?

我认为问题在于:

when('/things', {templateUrl: 'partial.html', controller: ThingCtrl})
这是告诉Angular指向ThingCtrl对象,该对象未定义并导致错误

尝试将控制器名称用引号括起来,如下所示:

when('/things', {templateUrl: 'partial.html', controller: 'ThingCtrl'})

这应该允许Angular正确使用依赖项注入。

是否需要使用
myApp.ThingCtrl
替代?可能的重复项
when('/things', {templateUrl: 'partial.html', controller: 'ThingCtrl'})