如何使用JS角当我加载AMD模块? [英] How do I load AMD modules when using Angular JS?

查看:113
本文介绍了如何使用JS角当我加载AMD模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于一些奇怪的原因,角JS有自己的模块系统既不是AMD也不CommonJS的

For some strange reason Angular JS has its own module system that is neither AMD nor CommonJS.

我在AMD的格式许多现有的模块。我想在一个角度应用程序来使用它们。

I have many existing modules in AMD format. I would like to use them in an Angular app.

我想避免重写任何AMD模块。如果可能的话,我也想避免采用了棱角分明的自己的模块系统。

I would like to avoid rewriting any AMD modules. If possible, I would also like to avoid using Angular's own module system.

是否有可能采用了棱角分明时使用AMD模块?是有可能避免角的自定义模块系统?

Is it possible to use AMD modules when using Angular? is it possible to avoid Angular's custom module system?

推荐答案

您不能代替角的模块定义与AMD定义。你必须包装在AMD的角code定义了。

You cannot replace Angular's module definitions with AMD defines. You have to wrap your Angular code in AMD defines for now.

另外需要注意的是有没有真正的办法此刻懒加载模块。你必须最终要求所有你会在你的应用程序在你的主角模块定义使用角模块,因此采用AMD的好处是有限的现在。

Another thing to note is there is no real way to "lazy load" modules at the moment. You'll have to eventually require all the angular modules you're going to use in your application in your main angular module definition, so the benefits of using AMD is limited for now.

开发团队说,他们会在未来的某个时刻,这是目前包装在AMD文件的唯一理由支持延迟加载。

The dev team says they'll support lazy loading at some future point, which is the only reason to wrap your files in AMD now.

这篇关于如何使用JS角当我加载AMD模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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