The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

AngularJS Architecture: ui-router state params for sharing information

AngularJS Architecture: ui-router state params for sharing information

4:53
Let's learn how to pass information from one state to another within Eggly. We learn how to define a state so that it has parameters in its definition and then read those parameters using the $stateParams service.
Watch this lesson now
Avatar
egghead.io

Let's learn how to pass information from one state to another within Eggly. We learn how to define a state so that it has parameters in its definition and then read those parameters using the $stateParams service.

Avatar
Alex

Hi! In your example, you reference the BookmarksCtrl in the stateProvider configuration for bookmarks, but the controller is defined in another file. Is that valid because the categories.bookmarks is injected as a dependency in app.js, and put into an app-wide scope as a reference?

In reply to egghead.io
Avatar
Aaron Endsley

$stateParams does not seem to be passing anything when i console log that particular object or try to change the url string it just reloads

In reply to egghead.io
Avatar
Lukas

Hey Aaron,
How are you forming the URL string? If you are just trying to do something like localhost:3000/Development, that will not work and will produce the "reloading" result. What you need to do is prepend the actual category name with the "categories" string, like so: localhost:3000/**categories**/Development. Hope that helps!

In reply to Aaron Endsley
Avatar
Steven

Hi @Alex
I was also wondering this. Did you figure it out?

Steven

In reply to Alex
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?