然而,随着新项目的另一个令人不安的情况:控制器在AngularJS不承认1.5.7
继控制器代码:
(function() {
'use strict';
angular
.module('offerRequest', [])
.controller('offerRequestCtrl', offerRequestCtrl);
offerRequestCtrl.$inject = ['$scope', '$rootScope', '$location'];
function offerRequestCtrl($scope, $rootScope, $location) {
// controller code starts here.
/* jshint validthis:true */
var vm = this;
vm.title = 'offerRequestCtrl';
activate();
function activate() { }
}
})();
用下面的路由:
// state for requesting offers
.state('offerrequest', {
url: '/offerrequest',
templateUrl: 'app/components/offerrequest/offerrequest.html',
controller: 'offerRequestCtrl'
})
导致以下错误消息:
Argument 'offerRequestCtrl' is not a function, got undefined
试图定义它的旧式:
angular.module('offerRequest', [])
.controller('offerRequestCtrl', function offerRequestCtrl() {
});
抛出了同样的错误。在我想与之合作的第一个实施中,我可能会做错什么?
你用过'.module( 'offerRequest',[])'某处其他? – Satpal
你能提供一个plunkr或jsfiddle吗? – vjarysta
@satpal是的,我正在使用另一项服务。那是不正确的方式?我删除了服务,它仍然抛出相同的错误。 – poptard