以下在控制台中返回错误“ReferenceError: ThingCtrl is not defined”
var myApp = angular.module('myApp', []);
myApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/things', {templateUrl: 'partial.html', controller: ThingCtrl}).
when('/things/:id', {templateUrl: 'detail.html', controller: ThingCtrl}).
otherwise({redirectTo: '/things'});
}]);
myApp.controller('ThingCtrl', ['$scope', '$routeParams', function($scope, $routeParams) {
$scope.thing = [
{
'title':'first thing',
'first':'one',
'second': 'two',
'third': 'three'
}
];
}]);
但是,当控制器定义为:
function ThingCtrl($scope, $routeParams) {
$scope.thing = [
{
'title':'first thing',
'first':'one',
'second': 'two',
'third': 'three'
}
]
};
为什么它不能使用模块化语法?