How to pass parameters in pop method of ionic2

后端 未结 8 1700
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 07:04

I tried passing parameters in push method of ionic2. like this

this.nav.push(SecondPage, {
    thing1: data1,
    thing2: data2
});

but is ther

8条回答
  •  南旧
    南旧 (楼主)
    2021-02-04 07:35

    If you are using ionic-angular application, you can use ionic-angular Events

    page1.ts

    import { Events,NavController } from 'ionic-angular';
    
    export class page1 {
    
        constructor(private events: Events,
                    private nvCtrl: NavController
                   ) {}
    
         goToPage2() {
             this.navCtrl.pop();
             this.event.publish('your-event');
     }
    
    }
    

    page2.ts

    import { Events} from 'ionic-angular';
    
    export class page1 {
    
        constructor(private events: Events,
                    private nvCtrl: NavController
                   ) {}
    
         ionViewDidLoad() {
            this.events.subscribe('your-event');
      }
    

    }

提交回复
热议问题