How do I load AMD modules when using Angular JS?

走远了吗. 提交于 2019-12-03 16:08:58

You do need to define Angular components in the "Angular way" (ex. angular.module('yourApp').directive('someDirective', ...)), but you can certainly use AMD both for wrapping Angular components and for pulling in non-Angular components to Angular. Check out this seed project.

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!