我玩弄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