范围继承失败,具有多个命名的视图?

时间:2014-06-17 13:49:44

标签: angularjs angularjs-scope angularjs-routing angular-ui-router

从(Plnkr)移动时会中断:

.state('home', {url: '/home', template: '<pre>{{parentProp}}</pre>',
                controller: function ($scope) {$scope.parentProp = ['home'];}})

收件人(Plnkr):

.state('home', {url: '/home', views: {'': {template: '<pre>{{parentProp}}</pre>'}},
                controller: function ($scope) {$scope.parentProp = ['home'];}})`

具体来说,我想将'sidebar'状态作为辅助状态添加到'home'

1 个答案:

答案 0 :(得分:1)

视图需要自己的控制器:

.state('home', {url: '/home',
                views: {'': {template: '<pre>{{parentProp}}</pre>',
                             controller: function ($scope) {
                                             $scope.parentProp = ['home'];
                                         }
                             }
                        },
                })`

http://plnkr.co/edit/giW3XRspEV7SEPM1UDeC?p=preview