A T A T - 1 month ago 19
AngularJS Question

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

A T A T
Answer

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

Comments