无法访问 angular-ui-router 状态内的视图 [英] Cant access a view within a state in angular-ui-router

查看:25
本文介绍了无法访问 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆