简体   繁体   English

离子框架调用视图中的ui-router问题

[英]ui-router issue in ionic framework calling views

I have an app in ionic framework using the tabs example for the most part. 我大部分使用选项卡示例在ionic框架中有一个应用程序。 However in one of the views, I want the user to be able to click an item and go into another view based on that item. 但是,在其中一个视图中,我希望用户能够单击一个项目并基于该项目进入另一个视图。

However, whenever you click on an item, it loads the correct view, but doesn't call the template file for that view. 但是,每当您单击某个项目时,它都会加载正确的视图,但不会调用该视图的模板文件。

Here's what I have in my router (note non-relevant sections are left out) 这是我路由器中的物品(请注意,不相关的部分被省略了)

$stateProvider.state('tab', {
  url: "/tab",
  abstract: true,
  templateUrl: "templates/tabs.html"
}).state('tab.dash', {
  url: '/dash',
  views: {
    'tab-dash': {
      templateUrl: 'templates/tab-dash.html',
      controller: 'LoginController'
    }
  }
}).state('tab.friend-detail', {
  url: '/friend/:friendId',
  views: {
    'tab-friends': {
      templateUrl: 'templates/friend-detail.html',
      controller: 'FriendDetailCtrl'
    }
  }
}).state('tab.buy', {
  url: '/buy',
  views: {
    'tab-buy': {
      templateUrl: 'templates/buy.html', 
      controller: 'PaymentController'
    }
  }
}).state('tab.account', {
  url: '/account',
  views: {
    'tab-account': {
      templateUrl: 'templates/tab-account.html',
      controller: 'AccountController'
    }
  }
}).state('tab.order', {
  url: '/account/order/:id', 
  views: {
    'tab-order': {
      templateUrl: 'templates/order-view.html', 
      controller: 'OrderController'
    }
  }
})

$urlRouterProvider.otherwise('/tab/dash'); $ urlRouterProvider.otherwise( '/标签/破折号');

In my controller I have: 在我的控制器中,我有:

$scope.viewOrder = function(id) {   
    $state.go('tab.order', {id:id});
};

In templates/tab-account.html I have: 在templates / tab-account.html中,我有:

<ion-view title="Account">
<ion-content class="has-header padding">
<h1>Account</h1>

<h2>Your orders</h2>

<div class="card" ng-repeat="booking in bookings">
  <div class="item item-text-wrap">
    <b><a ng-click="viewOrder(booking.id)">{{ booking.carpark.city }}</a></b> on <b>{{ booking.date | date:'dd.mm.yyyy' }}</b>
  </div>
</div>

Then the item specific view is as followed: 然后,项目特定视图如下:

<ion-view title="Order">
  <ion-content class="has-header padding">
      <h1>Your Order</h1>
      <p>Test</p>
      Order #: {{orderNumber}}
  </ion-content>
</ion-view>

That last view basically doesn't appear, even though the url changes from tab/account to /tab/account/order/1 即使url从tab/account更改为/tab/account/order/1 ,该最后一个视图也基本上不会出现

I've asked a few StackOverflow questions regarding ionic recently, apologies if people keep coming across them and quite rightly think I'm an idiot :/ 我最近问了一些关于离子的StackOverflow问题,如果人们继续遇到它们,我深表歉意,并且很正确地认为我是个白痴:/

Thanks in advance! 提前致谢!

You need a ui-view in your base view. 您需要在基本视图中使用一个ui视图。 When you nest states, the nested view is displayed inside the base view wherever you have a ui-view element: <div ui-view></div> . 当您嵌套状态时,无论您有ui-view元素<div ui-view></div>哪里,嵌套视图都会显示在基本视图中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM