5

Using angularjs and ui-router can I:

A.) Define custom variables when defining my state (see 'data' below). I currently do this with success, wanted to make sure its proper.

.state('parent', {url:'/parent', templateUrl: 'views/parent.html', abstract: true, data: {stuff: 'stuff'}})

B.) Have my child state inherit that variable data ( How? )

.state('parent.child',   {url:'/child', templateUrl: 'views/parent.child.html', data: parent.data})

?

1 Answer 1

5

You don't specify "data" into the child state, is already inherited from parent/abstracted state. You access it by :

$state.current.data
Sign up to request clarification or add additional context in comments.

3 Comments

took me a while to get back to the code to test this. I swear i tried it, but I guess not. Works fine!
did you mean $state.$parent.data ?
For now, the right object path to the parent item will be $state.$current.parent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.