如何在一页中定义两个角度应用程序/模块?

编程入门 行业动态 更新时间:2024-10-28 22:24:09
本文介绍了如何在一页中定义两个角度应用程序/模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试将两个 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/api/ng.directive:ngApp

另见

https://groups.google/d/msg/angular/lhbrIG5aBX4/4hYnzq2eGZwJhttp://docs.angularjs/api/angular.bootstrap

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

更多推荐

[db:关键词]

本文发布于:2023-04-22 09:18:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1019715.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   模块   角度   定义   两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!