Skip to content

Demo using services and broadcast messaging to share data between controllers in AngualrJS

Notifications You must be signed in to change notification settings

jondejong/angular-controller-messaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Angular Controller Messaging

Demo using services and broadcast messaging to share data between controllers in AngualrJS

I recently wrote a blog post with some basic lessons learned after using AngularJS for a while. In it I briefly described a pattern of using broadcast messages with services to share data between controllers in AngularJS. I was asked if there were any examples online. Here is an example.

This consists of an index.html file, two JavaScript files (one for the controllers and one for the service), and a basic CSS file. You can just open the index.html file in a browser (I use Chrome. I have not tested this in IE) to see it work. The page consists of 3 divs, each controlled by its own controller, with all controllers sharing data via the service.

This pattern can be useful when you have multiple controllers on a page, some of which need to know when data managed by another controller has been changed.

About

Demo using services and broadcast messaging to share data between controllers in AngualrJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published