简体   繁体   中英

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

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/

The key was the module() function in angular-mocks. Now it works using the string controller name as defined inside the module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM