问题
It breaks when moving from (Plnkr):
.state('home', {url: '/home', template: '<pre>{{parentProp}}</pre>',
controller: function ($scope) {$scope.parentProp = ['home'];}})
To (Plnkr):
.state('home', {url: '/home', views: {'': {template: '<pre>{{parentProp}}</pre>'}},
controller: function ($scope) {$scope.parentProp = ['home'];}})`
Specifically I have a 'sidebar'
state I want to add as a secondary state to 'home'
.
回答1:
The view needs its own controller:
.state('home', {url: '/home',
views: {'': {template: '<pre>{{parentProp}}</pre>',
controller: function ($scope) {
$scope.parentProp = ['home'];
}
}
},
})`
http://plnkr.co/edit/giW3XRspEV7SEPM1UDeC?p=preview
来源:https://stackoverflow.com/questions/24265610/scope-inheritance-fails-with-multiple-named-views