无法访问 angular-ui-router 状态内的视图 [英] Cant access a view within a state in angular-ui-router
问题描述
我试图链接到一个子状态,但不知道如何让它工作.这是链接:
I am trying to link to a substate and can't figure out how to get it to work. Here is the link:
<a ui-sref="tab.communityDashboard" class="button button-block button-large"><i class="icon ion-home"></i><br />Community Directory</a>
这是路线:
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
// Each tab has its own nav history stack:
.state('tab.communityDashboard', {
url: '/communitydashboard',
views: {
'tab-communityDashboard': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
然后最终:
$urlRouterProvider.otherwise('/home');
这是视图的内容:
<ion-view view-title="tab-communityDashboard">
<ion-content>
yolo yolo yolo
</ion-content>
</ion-view>
我也尝试访问 localhost:8100/#/communitydashboard 但它只是将我重定向到家.我该如何解决这个问题.
I tried also going to localhost:8100/#/communitydashboard but it just redirects me home. How do I fix this.
推荐答案
您需要一个 <ion-nav-view>
您希望在其中显示您的视图,并且由于您正在使用带有状态的视图,您需要在视图名称中包含 name 属性,因此类似于 <ion-nav-view name="tab-communityDashboard">
You need an <ion-nav-view>
where you want your view to show up, and since you're using views with your states, you'll need to include the name attribute with the name of the view, so something like <ion-nav-view name="tab-communityDashboard">
http://ionicframework.com/docs/api/directive/ionNavView/
http://learn.ionicframework.com/formulas/navigation-and-routing-part-1/
这篇关于无法访问 angular-ui-router 状态内的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!