如何注入D3依赖? [英] how to inject d3 dependency?

查看:132
本文介绍了如何注入D3依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来angularjs,我注入D3在main.js如下:

 函数(角){
            使用严格的;        angular.module('主',['ngFileUpload','ngCookies','ui.router','D3'])
         .constant('_',window._);      })(window.angular);

但我得到一个错误:

 未捕获的错误:[$喷油器:modulerr]
       无法实例化模块主要是由于:
           错误:[$喷油器:modulerr]未能实例由于模块D3:
         错误:[$喷油器:NOMOD]模块D3不可!你要么拼写错误的模块名称,或忘了加载它。如果注册一个模块,确保指定的依赖关系作为第二个参数。


解决方案

如果您使用的是普通D3库你不注入角的依赖关系。

 <脚本SRC =htt​​ps://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js字符集=utf-8 >< / SCRIPT>

您可以使用d3.js角指令或D3包装角指令,我建议你:

I am new to angularjs ,i inject d3 in main.js as follow:

      function (angular) {
            'use strict';

        angular.module('main', ['ngFileUpload', 'ngCookies', 'ui.router', 'd3'])
         .constant('_', window._);

      })(window.angular);

but i get an error:

       Uncaught Error: [$injector:modulerr] 
       Failed to instantiate module main due to:
           Error: [$injector:modulerr] Failed to instantiate module d3 due to:
         Error: [$injector:nomod] Module 'd3' is not available! You either              misspelled the module name or forgot to load it. If registering a module ensure              that you specify the dependencies as the second argument.

解决方案

If you are using normal d3 library you dont inject angular dependencies.

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>

You can use d3.js angular directives or d3 "wrappers" angular directives, i recommend you:

这篇关于如何注入D3依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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