I have a directive, that in its scope has an object. This is static information right now and I want to make this visible for every controller in my app. Is there any way to do this?
Asked
Active
Viewed 34 times
0

Jonathan Hall
- 75,165
- 16
- 143
- 189

squeezy00
- 3
- 3
-
1Create service to share the object, you can access it after inject with any controller or directive. See https://stackoverflow.com/questions/21919962/share-data-between-angularjs-controllers – Sachink Apr 16 '18 at 13:33
-
This worked perfectly, thanks! – squeezy00 Apr 16 '18 at 13:41
1 Answers
0
Use global scope ($rootScope ) for example, if you want to use it everywhere
UPDATE: some example and answer here: How do I use $rootScope in Angular to store variables?

Sh. Pavel
- 1,584
- 15
- 28
-
-
-
@Sh.Pavel this worked aswell and I will use this as a solution, since the information I want to store is call-specific so it makes no sense to store it in a directive or factory. Thanks! – squeezy00 Apr 17 '18 at 12:39