angularjs ui-router父状态

Mee*_*ker 5 angularjs

使用angularjs和ui-router我可以:

A.)定义我的状态时定义自定义变量(参见下面的"数据").我目前这样做是成功的,想要确保它正确.

.state('parent', {url:'/parent', templateUrl: 'views/parent.html', abstract: true, data: {stuff: 'stuff'}})
Run Code Online (Sandbox Code Playgroud)

B.)让我的孩子继承可变数据(How?)

.state('parent.child',   {url:'/child', templateUrl: 'views/parent.child.html', data: parent.data})
Run Code Online (Sandbox Code Playgroud)

?

小智 5

您没有将"数据"指定为子状态,已经从父/抽象状态继承.您可以通过以下方式访

$state.current.data
Run Code Online (Sandbox Code Playgroud)