应用初始化后angularjs注入模块 [英] angularjs inject module after app initialization

查看:31
本文介绍了应用初始化后angularjs注入模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,几天来我一直在尝试这样做,但没有运气.

Hello everyone I've been trying to do this with no luck for a few days.

无论如何都可以异步加载一些 js 脚本(包含 angular 模块)并在初始化后将它们注入到正在运行的应用程序中.

is there anyway to load asynchronously some js scripts(which contain angular modules) and inject them to the running app after it has been initialized.

基本上我有一个容器 DOM 元素,它将填充一些从服务器请求的 HTML,基于此 HTML 代码,我将决定需要哪些 js 文件(模块),然后将它们异步加载到 angular应用程序并使用新注入的模块编译内容.

Basically I have a container DOM element that will be populated with some HTML requested from the server, based on this HTML code I will decide which js files (modules) will be required, then load them asynchronously inject the modules to the angular app and compile the content with the new injected modules.

我尝试过,但每次我执行注入模块的引导程序方法时,主控制器都会启动并擦除我的所有范围状态.:(

I tried but every time I do the bootstrap method injecting the module the Main Controller fires up and erases all my scope state. :(

这里有什么帮助吗?

推荐答案

也许这有帮助?

app.requires.push("myModule");

当你只有访问权限时注​​入模块到模块变量

这篇关于应用初始化后angularjs注入模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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