以下命令在控制台中返回错误“ReferenceError:未定义ThingCtrl”
原文链接:https://www.f2er.com/angularjs/141244.htmlvar 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','third': 'three' } ] };
为什么使用模块化语法不起作用?