【问题标题】:What is difference between module and library in Angular JsAngular Js中的模块和库有什么区别
【发布时间】:2016-06-21 03:58:32
【问题描述】:

我正在研究nvd3c3js,它们都依赖于d3js。对于nvd3,我们需要注入“nvd3”作为依赖注入,而对于c3js,我们只提供文件路径,我们不会注入任何东西。

谁能解释实现nvd3c3js的区别。

谢谢。

【问题讨论】:

    标签: angularjs d3.js nvd3.js c3.js


    【解决方案1】:

    似乎你需要 提供文件路径 注入依赖项。我认为您将angular-nvd3 称为nvd3

    angular-nvd3 是一个封装了原始nvd3 图表库的角度模块。它有 angular directives 帮助您在 Angular 应用程序中使用 nvd3 图表(带有绑定等)。

    例如(view it online):

    <nvd3 options="options" data="data" class="with-3d-shadow with-transitions"></nvd3>
    

    你必须在 Angular 中使用 "dependecy injection" 是因为 Angular 与第三方模块集成的方式:当你想使用第三方时 Angular 模块,您需要在应用模块定义中将其声明为依赖项。

    例如,此语法意味着您声明了一个名为 myApp 的 Angular 应用程序,它依赖于 angular-nvd3

    angular.module('myApp', ['nvd3'])
        .controller(...)
        .service(...)
    

    除此之外,您还需要在主 html 文件中包含 3rd 方库代码,例如:

    <meta charset="utf-8">  <!-- it's important for d3.js -->
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/d3/d3.js"></script>
    <script src="bower_components/nvd3/nv.d3.js"></script> <!-- or use another assembly -->
    <script src="bower_components/angular-nvd3/dist/angular-nvd3.js"></script>
    <link rel="stylesheet" href="bower_components/nvd3/nv.d3.css">
    

    【讨论】:

      猜你喜欢
      • 2017-02-25
      • 2013-06-04
      • 2011-09-16
      • 2023-03-28
      • 2021-07-08
      • 2011-04-10
      • 2013-01-11
      相关资源
      最近更新 更多