Scope inheritance fails with multiple-named views?

送分小仙女□ 提交于 2019-12-11 08:42:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!