如何在模块化减轻AngularJS? [英] How is modularity mitigated in AngularJS?

查看:157
本文介绍了如何在模块化减轻AngularJS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经打与AngularJS种子应用程序,我注意到,对于应用最依赖(控制器,指令,过滤器,服务)被加载了前面。我想知道如何模块化的角度应用分成更小的字节,其中除非需要依赖不会被加载。

I've been playing with the seed app for AngularJS and I noticed that most dependencies (controllers, directive, filters, services) for the app are loaded up front. I was wondering how to modularize an Angular app into smaller bytes, where dependencies aren't loaded unless required.

例如,如果我有一个大的应用程序,它有一个车,添加/编辑送货地址,搜索结果,产品细节,产品列表等......在购物网站上的用户可能永远不会遇到任何的这些观点,但它看起来像(从种子应用程序),对这些所有视图code在启动时加载

For example, if I had a large application that had a cart, add/edit shipping address, search results, product details, product lists, etc... A user on a shopping site may never encounter any of these views, but it looks like (from the seed app) that the code for these all views are loaded in at startup.

如何在模块化减轻AngularJS?

How is modularity mitigated in AngularJS?

推荐答案

我一直在玩与最近需要的模块和角度,我已经实现泛音和控制器的延迟加载。

I've been playing lately with require modules and angular and I've implemented lazy loading of partials and controllers.

它无需任何修改角源(版本1.0.2)轻松完成。

It can be easily done without any modifications to Angular sources (version 1.0.2).

存储库:<一href=\"https://github.com/matys84pl/angularjs-requirejs-lazy-controllers\">https://github.com/matys84pl/angularjs-requirejs-lazy-controllers 。

还有一个使用yepnope实现( https://github.com/cmelion/angular-yepnope )由查尔斯Fulnecky的。

There is also an implementation that uses yepnope (https://github.com/cmelion/angular-yepnope) made by Charles Fulnecky.

这篇关于如何在模块化减轻AngularJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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