[英]How do you get a reference to an angularjs controller defined in a module?
I have a jasmine test and I can't get a reference to the controller constructor function as it was defined in a module. 我有一个茉莉花测试,我无法获得对模块中定义的控制器构造函数的引用。 See my gist here https://gist.github.com/hcabnettek/5222429
请参阅我的要点https://gist.github.com/hcabnettek/5222429
I need to unit test a controller defined like 我需要对像这样定义的控制器进行单元测试
angular.module('foo', []).controller('fooCtrl', function($scope){ $scope.foo = 'bar'; });
Can anyone possibly help me out? 有人可以帮帮我吗? Thanks!
谢谢!
http://www.itaware.eu/2012/10/19/angularjs-unit-tests-and-end-to-end-tests/ http://www.itaware.eu/2012/10/19/angularjs-unit-tests-and-end-to-end-tests/
The key was the module() function in angular-mocks. 关键是角度模拟中的module()函数。 Now it works using the string controller name as defined inside the module.
现在它使用模块内定义的字符串控制器名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.