我玩弄https://github.com/angular/angular-seed像angular.module定义测量角控制器( '对myApp')。控制器(
控制器在应用程序定义/ controllers.js这样
'use strict';
function MyCtrl1() {}
MyCtrl1.$inject = [];
这并未“T通过jshint如MyCtrl1在app/app.js在我的全局列表中引用而不是。
根据Brian Ford和其他人我看过的首选风格是
angular.module('myApp').controller('MyCtrl1', [], function() {});
我喜欢这个更好,因为它不是在全球范围内,但现在我的testacular规格失败,因为这不工作了:
var myCtrl1;
beforeEach(function(){
myCtrl1 = new MyCtrl1();
});
我如何获得这个控制器的引用,其定义用于测试目的的“首选”样式?
这可能是我已经anwsered [这里]同样的问题(http://stackoverflow.com/questions/15799853/angularjs-testing-controller/15801116#15801116)你需要添加'beforeEach(module('myApp'));' – Xesued 2013-04-08 00:05:30