错误:[$喷油器:unpr]未知提供商:$ stateProvider< - $状态 [英] Error: [$injector:unpr] Unknown provider: $stateProvider <- $state

查看:556
本文介绍了错误:[$喷油器:unpr]未知提供商:$ stateProvider< - $状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行下面的单元测试提供了错误:[$喷油器:unpr]未知提供商:$ stateProvider< - $状态。我在因缘文件所附的角-UI-router.min.js。

 描述(单元测试功能(){  变量$ rootScope,$喷油器,$状态;
  的console.log(你好);  beforeEach(注(功能(_ $ rootScope_,_ $ STATE_,_ $ injector_,$ templateCache){
    的console.log(hello1);
    $ rootScope = _ $ rootScope_;
    $喷油器= _ $ injector_;
    $状态= _ $ STATE_;
  }));  描述(国家,函数(){
    它(验证状态的配置功能(){
        变种配置= $ state.get(DRaaS);
        的console.log(配置,CC);
    });
  });
});


解决方案

您还没有加载的任何模块,所以根本没有服务。您beforeEach前补充一点:

  beforeEach(模块('ui.router'));

Executing below unit test gives "Error: [$injector:unpr] Unknown provider: $stateProvider <- $state". I have attached the angular-ui-router.min.js in karma file.

 describe("Unit tests", function() {

  var $rootScope, $injector, $state;
  console.log("hello");

  beforeEach(inject(function(_$rootScope_, _$state_, _$injector_, $templateCache) {
    console.log("hello1");
    $rootScope = _$rootScope_;
    $injector = _$injector_;
    $state = _$state_;
  }));

  describe("states", function() {
    it("verify state configuration", function() {
        var config = $state.get("DRaaS");
        console.log(config, "cc");
    });
  });
});

解决方案

You haven't loaded any module, so no service at all is available. Add this before your beforeEach:

beforeEach(module('ui.router'));

这篇关于错误:[$喷油器:unpr]未知提供商:$ stateProvider&LT; - $状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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