该应用与我的模块正常运行。但是建立以下模拟返回:
$global_vars is not defined
我想我不会正确地注入模块。我在这里缺少什么?
describe('CalendarController', function() {
beforeEach(module("$global_vars"));
beforeEach(inject(function($rootScope, $controller, $location, $injector, $global_vars) {
var $httpBackend;
$httpBackend = $injector.get('$httpBackend');
return this.controller = $controller(CalendarController, {
$scope: this.scope,
$location: $location,
$global_vars: $global_vars
});
}));
return it("can be instantiated", function() {
return expect($global_vars).not.toBeNull();
});
});
注意:这是对香草js的coffeescript翻译
更新
好的,通过这样做我得到另一个,可能更好的错误?
Error: Unknown provider: $httpProvider <- $http <- $global_vars
describe 'CalendarController', ->
beforeEach module("$global_vars")
beforeEach module("GlobalService")
beforeEach inject ($rootScope, $controller, $location, $injector) ->
$injector = angular.injector [ '$global_vars' ]
$global_vars = $injector.get('$global_vars')
$global_vars = $injector.get('$global_vars')
@controller = $controller CalendarController, {$scope: @scope, $location: $location}
我的骨干骨干.js
angular.module("VarsService", []).factory "$global_vars", ["$http", '$location', ($http, $location) ->
global_vars.get_calendar = ->
console.log 'blam!'