范围继承失败,多命名的看法? [英] Scope inheritance fails with multiple-named views?
本文介绍了范围继承失败,多命名的看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
其移动时打破( 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'];}})`
具体来说,我不得不'家'
A 侧边栏
状态我想添加为辅助状态。
Specifically I have a 'sidebar'
state I want to add as a secondary state to 'home'
.
推荐答案
该视图需要它自己的控制器:
The view needs its own controller:
.state('home', {url: '/home',
views: {'': {template: '<pre>{{parentProp}}</pre>',
controller: function ($scope) {
$scope.parentProp = ['home'];
}
}
},
controller: function ($scope) {$scope.parentProp = ['home'];}})`
http://plnkr.co/edit/giW3XRspEV7SEPM1UDeC?p=$p$ PVIEW
这篇关于范围继承失败,多命名的看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文