Sharing Data Between Controllers

Share this video with your friends

Send Tweet

If AngularJS Controllers are the glue of an application, how do they communicate and pass data around? This introduction to service factories will shed some light on that question.

Elgs
Elgs
~ 10 years ago

These two controllers are in a parent-child relationship. How about sharing data between two side-by-side controllers?

Abdo
Abdo
~ 10 years ago

To share the greeting service between the controllers, we used the variable name "greeting" in the controller's first argument. Does this not break after js minification? How can we work around this?

Abdo
Abdo
~ 10 years ago

It does break the after minification. This is how you work around it: .controller('FirstCtrl', ['greeting', function(foo) { // foo is the greeting service in here }])

John Lindquist
John Lindquist(instructor)
~ 10 years ago

Check out this lesson on using a build tool to make all your angular code "min safe".

https://egghead.io/lessons/angularjs-using-ng-annotate-for-min-safe-angularjs

arpan
arpan
~ 10 years ago

What editor are you using?

Daniel
Daniel
~ 9 years ago

webstorm

roberto
roberto
~ 9 years ago

Hello there, i'm a bit new to Angular. So thank you for these courses :)

So here's a noob question. I'm trying to follow the lectures by also reading the Rout code module to have a deeper understanding:

https://code.angularjs.org/1.4.7/angular-route.js

Inside that code- I can't find: (1) ui-view or (2) ui- sref.

So Where are we getting those two functions from ?

Thanks !

rui
rui
~ 9 years ago

I think what you should refer to is angular-ui-router rather than angular-router.

~ 9 years ago

Where can I find the code for this? The code below the video is not the one thats shown in the video

Joel Hooks
Joel Hooks
~ 9 years ago

Where can I find the code for this? The code below the video is not the one thats shown in the video

What you see is what you get!

mlaksv100
mlaksv100
~ 9 years ago

Is that deliberate? to post different version of code below the video?