Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  • Overview
  • Transcript

1.2 Sharing Data Between Angular Controllers

In this lesson, I'll show you some simple techniques for sharing data between Angular controllers. Controllers don't share scope, so they can't share data between them without a bit of extra work. I'll demonstrate a couple of ways in which controllers can pass data to each other with services, and also a way to pass data as a parameter to the state for UI-Router.

Code Snippet:

Here's an example of a service that allows an array of results data to be shared between controllers.

If you want to pass data as a state parameter to UI-Router, you can do it with a link like this:

You then declare this pet param to a state in the $stateProvider.state configuration and access it in your controller with $stateParams.pet.

1.Sharing Data Between Angular Controllers
2 lessons, 11:58

Free Lesson
1.1
Introduction
00:42

1.2
Sharing Data Between Angular Controllers
11:16