简单的父模块
angular.module('app', ['ngRoute', 'app.services']);
Run Code Online (Sandbox Code Playgroud)
简单的子模块
angular.module('app.services');
Run Code Online (Sandbox Code Playgroud)
我们可以访问ngRoute此服务,因为它的依赖性app.servies是依赖性app.
angular.module('app.services').factory('myService', function($route) {
// used $route in here
});
Run Code Online (Sandbox Code Playgroud)
在测试服务时jasmine,模拟app.services模块的最佳方法是什么,以便我可以访问$route?
我能想到的最好的方法是:
beforeEach(function(){
module('app');
module('app.services');
});
Run Code Online (Sandbox Code Playgroud)
但最好只需注入ngRoute而不必模拟app模块.
| 归档时间: |
|
| 查看次数: |
542 次 |
| 最近记录: |