我如何合并两个AngularJS应用为主要应用的模块? [英] How do I combine two AngularJS apps as modules of a main app?

查看:191
本文介绍了我如何合并两个AngularJS应用为主要应用的模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另一个基本问题AngularJS。我有两个AngularJS应用, slider.js (AngularUI)及 json.js

Another basic AngularJS question. I have two AngularJS apps, slider.js (AngularUI) & json.js.

我想他们两个到一个页面上运行。其实,我想同时使用它们:我想渲染滑块内我的JSON渲染。什么是做到这一点的最好方法是什么? <一href=\"http://stackoverflow.com/questions/15641730/angular-js-directives-in-different-modules/15644492#15644492\">This回答建议创建一个主要的应用程序和放大器;双方呼吁在它这些。那是当我想在页面上的同一个地方这两个应用的功能,或者我应该工作相结合的apps-以及如何总会有去这样做?一个很好的解决方案。

I want them both to run on a page. In fact, I want to use them together: I want to render sliders within my JSON renders. What is the best way to do this? This answer suggests creating a Main app & calling these both within it. Is that a good solution for when I want the functionality of both apps in the same place on the page, or should I be working on "combining" the apps- and how would one go about doing that?

我不工作的尝试,到目前为止是在这里:

My not-working attempt so far is here:

推荐答案

您需要添加滑块为因的myapp,那么在页面声明中使用的myapp,这样对myApp将所有元素(指令/控制器/过滤器等)在滑块应用也增加了。

You need to add the slider as dependent of myapp then use myapp in the page declaration, so that myApp will have all elements(directives/controllers/filters etc) added in slider app also.

var myApp = angular.module('myApp', ['ui.slider']);

然后

<html ng-app="myApp">

演示: Plunker

这篇关于我如何合并两个AngularJS应用为主要应用的模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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