如何在一页中定义两个角度应用程序/模块? [英] How to define two angular apps / modules in one page?

查看:16
本文介绍了如何在一页中定义两个角度应用程序/模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将两个 Angular 应用程序/模块添加到一个页面.在下面的小提琴中,您可以看到始终只有在 html 代码中引用的第一个模块才能正常工作,而第二个模块无法被 angular 识别.

I'm trying to add two angular apps / modules to one page. In the fiddles below you can see that always only the first module, referenced in the html code, will work correctly, whereas the second is not recognized by angular.

在这个 fiddle 中,我们只能执行 doSearch2 方法,而在这个 fiddle 中,只有 doSearch 方法可以正常工作.

In this fiddle we can only execute the doSearch2 method, whereas in this fiddle only the doSearch method works correctly.

我正在寻找如何将两个 Angular 模块正确放置到一页中的方法.

I'm looking for the way how to correctly place two angular modules into one page.

推荐答案

每个 HTML 文档只能自动引导一个 AngularJS 应用程序.在文档中找到的第一个 ngApp 将用于定义根元素以作为应用程序自动引导.要在 HTML 文档中运行多个应用程序,您必须使用 angular.bootstrap 手动引导它们.AngularJS 应用程序不能相互嵌套.-- http://docs.angularjs.org/api/ng.directive:ngApp

另见

这篇关于如何在一页中定义两个角度应用程序/模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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