我有一个控制器,如下所示。
(function () {
"use strict";
var app = angular.module('Demo')
.controller('MainController', ['$rootScope', '$scope', '$location', 'curUser',MainController]);
function MainController($rootScope, $scope, $location, curUser) {
//some logic here
}());
我尝试包含一个名为 ngIdle 的第三方模块,生成的代码如下所示。
(function () {
"use strict";
var app = angular.module('Demo', ['ngIdle'])
.controller('MainController', ['$rootScope', '$scope', '$location', 'curUser','Idle', function ($rootScope, $scope, $location, curUser, Idle) {
}]).config(function (IdleProvider, KeepaliveProvider) {
// configure Idle settings
IdleProvider.idle(5); // in seconds
IdleProvider.timeout(5); // in seconds
KeepaliveProvider.interval(2); // in seconds
})
.run(function (Idle) {
// start watching when the app runs. also starts the Keepalive service by default.
Idle.watch();
});
}());
现在我收到一个错误错误:[$injector:unpr] Unknown provider: curUserProvider <- curUser <- MainController。这是 curUser 工厂定义
(function () {
"use strict";
angular.module("services").factory("curUser", curUser)
function curUser() {}
}());