注入名称中带有点的工厂 [英] Injecting a factory with dots in name

查看:14
本文介绍了注入名称中带有点的工厂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Jasmine 中使用 angularjs 模拟注入方法来注入名称中带有点的服务.我尝试添加字符串标识符,但注入方法似乎不支持这一点.这是不可能的:

I need to use the angularjs mock inject method within Jasmine to inject a service with dots in the name. I tried to do add string identifiers but the inject method does not seem to support this. This is not possible:

beforeEach(inject(['$rootScope','MyApp.Factories.TestFactory', 
    function ($rootScope, testFactory) {

    //doSomeThing

}]));

还有其他方法可以解决这个问题吗?

Is there another way to handle this?

推荐答案

这个我没测试过,不过你应该可以自己从$injector中获取.像这样的:

I haven't tested this, but you can probably get it from the $injector yourself. Something like this:

beforeEach(inject(function($rootScope,$injector) {
    var testFactory = $injector.get('MyApp.Factories.TestFactory');
    //doSomeThing

}));

这篇关于注入名称中带有点的工厂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆