0

My code includes many modules. Each includes service or controller. There is a main module to connect others module.

var app = angular.module('abc', ['ngRoute','Trancontroller','Terminalcontroller','Settingcontroller','Usercontroller','Devicecontroller','Sidebar_service'])

But now how to share data between controller if they are in different modules. Thanks for help

Teppic
  • 2,506
  • 20
  • 26
co len
  • 81
  • 2
  • 11

2 Answers2

0

There're two ways to share same data among different controllers of different module, rootScope and factory

Example

$rootScope.test = "some value"

Rootscope is very easy to initiate it but Of two ways, I recommend using factory for most cases. Using rootScope might effect whole application, which might lead to global variable pollution

Naing Lin Aung
  • 3,373
  • 4
  • 31
  • 48
0

in addition to Naing Lin Aung's comment, also see this previous SO post of simply injecting one WHOLE module into another and getting access to all of it's controllers, services, factories, tigers, bears, oh my: How to share data between two modules in AngularJS?

GL!

Community
  • 1
  • 1
Shehryar Abbasi
  • 378
  • 2
  • 8