Meeker
Meeker

Reputation: 5979

Use resolve (or any data) in states custom data

Using angular 1.2 and ui-router 2.8

Was wondering if it was possible to inject data from either the resolve or $scope into a states custom data object. I know I can alter this data in a controller "$state.$current.data.key = value;" but this will not inherent to children.

Upvotes: 1

Views: 553

Answers (1)

Matt Metlis
Matt Metlis

Reputation: 691

I'm not sure about using the custom data the way you're asking - I haven't done that and I can't find an example of it in the docs.

You could define a resolve dependency on the parent, and the child will have access to it as long as it's injected as a dependency within the child as well. See this UI-Router wiki page for an example.

Upvotes: 1

Related Questions