How can we navigating through pages so we can create new object of a page from same page

廉价感情. 提交于 2019-12-11 17:23:42

问题


How can we create stack like structure for navigating through pages so we can create new object of a page from same page , here I want to go to SuperPage from SuperPage but angular routing does not supporting it , in IONIC3 we can achieve it very easily by push method of navCtrl but I want the navigation on the same page(SuperPage) in ionic 4 so how can we achieve this ??

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { NavController } from '@ionic/angular';

@Component({
  selector: 'app-super',
  templateUrl: './super.page.html',
  styleUrls: ['./super.page.scss'],
})
export class SuperPage implements OnInit {
  constructor(private router: Router, private navCtrl: NavController) { }
  nextPage() {
    //working in ionic3
    //this.navCtrl.push('SuperPage');

    //ionic4
    //1.not working 
    //this.navCtrl.navigateForward('super');

    //2.not working
    //this.navCtrl.navigateRoot('super');

    //3.not working
    // this.router.navigate(['super']);

      this.router.navigateByUrl('super');
  }


}

回答1:


There are two solution of above question

1) Modal Pages

You can call page like modal,Our modal page will be displayed above our super page and we can passed the information to the page, now we can access this information almost like we did in ionic v3.

https://ionicframework.com/docs/api/modal

2) Popover Pages

you can try Popover page it works technically like the modal.

https://ionicframework.com/docs/api/popover

i think you can go with Modal



来源:https://stackoverflow.com/questions/56738568/how-can-we-navigating-through-pages-so-we-can-create-new-object-of-a-page-from-s

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