A T
A T

Reputation: 13826

Scope inheritance fails with multiple-named views?

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'.

Upvotes: 1

Views: 389

Answers (1)

A T
A T

Reputation: 13826

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

Upvotes: 1

Related Questions