app.admin.routes.js
(function () {
'use strict';
angular
.module('app.admin')
.run(appRun);
appRun.$inject = ['routeHelper', 'app.core.services.notificationService'];
function appRun(routeHelper, notificationService) {
debugger;
routeHelper.configureRoutes(getRoutes());
function getRoutes() {
return [
{
state: 'admin',
url: '/admin',
templateUrl: 'app/features/admin/admin.html',
controller: 'Admin as vm',
resolve: {
// signalRConnection: function() {
// return notificationService.onReady;
// }
},
settings: {
navigation: {
group: "application",
label: "Admin",
//label: "navigation.admin",
icon: "fa-lock",
order: 2
}
//content: '<i class="fa fa-lock"></i> Admin'
}
}
];
}
}
})();
admin.js
(function () {
'use strict';
angular
.module('app.admin')
.controller('Admin', Admin);
Admin.$inject = ['logger'];
function Admin(logger) {
/*jshint validthis: true */
var vm = this;
vm.title = 'Admin';
activate();
function activate() {
logger.info('Activated Admin View');
}
}
})();
adminctrlSpec.js
describe(“AdminController”,function(){
var _logger; beforeEach(function() { module("app.admin", function ($provide) { $provide.value('routeHelper', { configureRoutes: function(routes) { } }); $provide.value('app.core.services.notificationService', { signalRConnection: function () { } }); }); }); beforeEach(function () { inject([ 'logger', function (logger) { debugger; } ]); }); it("asd", function() { debugger; });
});
我可以在所有其他规格中使用记录器。但是无法为admin.js注入。
beforeEach(function () {
> inject([
> 'logger', function (logger) {
> debugger;
> }
> ]);
> });
Error: [$injector:unpr] Unknown provider: loggerProvider <- logger
答案 0 :(得分:0)
(function () {
'use strict';
angular.module('app', [
'app.admin',
'app.modelling',
'app.layout'
]);
})();
问题解决了。我忘了添加beforeEach(function () { module("app"); });