[英]ui-router child view of an angularjs component not showing
我有一個angularjs組件(幾乎為空的標記)充當其子視圖(具有不同列/格式的標記)的外殼/父級。 我能夠看到該組件,但未加載任何子視圖。
ui路由器配置代碼:
.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('parent', {
url: '',
views: {
'parentComponent': {
component: 'parentComponent'
}
}
})
.state('parent.child', {
url: '/child',
templateUrl: 'child.html'
});
index.html的:
<body ng-app="app" >
<div ng-controller='RoutingCtrl'>
<parent-component></parent-component>
</div>
</body>
父級,它是一個組件:
<!DOCTYPE html>
<div>
<br />
<br />
<div>I am the parent, a angularjs component.</div>
<div>There sould be the nested/child view right below:</div>
<div ui-view></div>
</div>
兒童:
<div>Hi! I am the child!</div>
我的控制器告訴ui-router進入子視圖:
$state.go('parent.child');
我不想將父級聲明為抽象,因為在我的實際應用中,我在這里具有與父級組件視圖平行的視圖(它們共同構成多個命名視圖),而這些其他高級視圖(父級組件除外)必須無論子視圖如何都可見。
我正在使用angularjs 1.5.8和ui-router版本0.4.2
柱塞: http ://plnkr.co/edit/tBhVTjttMagaJzHQNvro?p=preview
您沒有提供要完成的詳細信息,因此根據當前的外觀,您有兩種選擇:要么在整個應用程序中使用ui-view
模板,要么使用ui-router
的父子關系或采用混合方法來加載組件,並在其中加載要顯示的狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.