问题描述
我没有在单个页面应用程序上使用angular,但是由于加载顺序问题,我想一次定义主应用程序模块.同时,我想在每个页面上插入/请求模块,而不要一概而论,因为并非所有JS文件都会在每个页面上加载.
I am not using angular on a single page application however I would like to define the main app module once due to load order issues. At the same time I would like to inject/require modules on a per page basis and not blanket as not all JS files will be loaded on every page.
我可以定义没有必需模块的应用程序吗?
Can I define the app with no required modules:
app = angular.module("app",[])
app = angular.module("app", [])
并且将它们从控制器注入还是在以后注入?
and have them injected from a controller or at a later stage?
推荐答案
否,目前尚不正式支持.引导AngularJS应用程序之前,必须将所有模块加载到浏览器中(并声明为主应用程序模块的依赖项).
No, this is not officially supported at the moment. All the modules must be loaded in a browser (and declared as a dependency of a main application module) before AngularJS application is bootstrapped.
这篇关于如何动态地将模块注入到主要的Angular应用程序模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!