Ila
Ila

Reputation: 3538

How do I combine two AngularJS apps as modules of a main app?

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

Here's slider.js as a Plunkr.

Here's json.js as a Plunkr.

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:

Plunkr of the two apps combined, not working

Upvotes: 0

Views: 2317

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388436

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']);

then

<html ng-app="myApp">

Demo: Plunker

Upvotes: 3

Related Questions