Cant access a view within a state in angular-ui-router

好久不见. 提交于 2019-12-25 06:46:14

问题


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>

and here is the route:

  .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'
      }
    }
  })

and then eventually:

$urlRouterProvider.otherwise('/home');

Here is the content of the view:

<ion-view view-title="tab-communityDashboard">
    <ion-content>
        yolo yolo yolo
    </ion-content>
</ion-view>

I tried also going to localhost:8100/#/communitydashboard but it just redirects me home. How do I fix this.


回答1:


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/



来源:https://stackoverflow.com/questions/36486390/cant-access-a-view-within-a-state-in-angular-ui-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!