捆绑"到&QUOT最好的办法;在AngularJS外部依赖 [英] Best way to "bundle" external dependencies in AngularJS

查看:81
本文介绍了捆绑"到&QUOT最好的办法;在AngularJS外部依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用AngularJS很容易分裂的应用程序,还包括我们要使用外部模块。但与方式,我们今天做到这一点的index.html可以与不同的外部引用被散落,很难看到哪个是真正由模块需要的。

With AngularJS it is easy to split up the application and also include external modules that we want to use. But with the way we do it today the index.html can be littered with the different external references and it's hard to see which is really needed by the modules.

有处理模块的依赖关系(如HTML模板,CSS和JS文件等),如何在外部包括一个好办法?

Is there a good way to handle how external dependencies of the modules (such as html templates, css and js files) are "included"?

在理想情况下,我们想只与参考外部使用的角度模块一起加入index.html的一个参考,这反过来又包括所需的相关性。这可能吗?

Ideally we would like to just add one reference in index.html along with the reference to the external used angular module and this in turn includes the needed dependencies. Is that possible?

推荐答案

由于角没有依赖装载机 ,你有两个选择:

As Angular doesn't have a dependency loader, you have two options:


  1. 使用第三方装载机如 RequireJS 是一个异步地获取文件。<​​/ li>
  2. 使用一个构建工具像browserify或步兵包装万事成的一个JavaScript文件然后可以包含。

  1. Use a third-party loader like RequireJS that fetches the files asynchronously one by one.
  2. Use a build-tool like browserify or Grunt to wrap everything into one javascript file that you can then include.

这篇关于捆绑&QUOT;到&QUOT最好的办法;在AngularJS外部依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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