离子使用弹出到特定页面

ionic using popTo specifc page

我正在使用 ionic2。

我需要 popTo 特定页面。

如果用户订购了产品需要authenticated.So进入登录页面。

我在登录后在 nav.push.user 中传递了查询参数。

这是我的代码

this.navCtrl.push('CustomershippingPage',{Page:'Signin'});

。 前往 CustomershippingPage。

如果用户返回,请单击导航后退按钮。

我检查查询参数值为 Signin 并且页面弹出到 cartPage

这是我的代码。

我试过了

this.navCtrl.popToRoot('CartPage');

但我收到这个错误

Cannot create property 'direction' on string 'CartPage'

为此调整您的代码

通过添加 #content

检查并确保您的 app.html 看起来像这样

app.html

 <ion-nav [root]="rootPage" #content></ion-nav>

yourpage.ts

import { Component, ViewChild } from '@angular/core';
import { NavController, Content } from 'ionic-angular';

...
export class YourTestPage{

   @ViewChild("content") nav: NavController;


   yourmethod(){
     this.nav.setRoot('CartPage');
   }

}