我们如何浏览页面,以便可以从同一页面创建页面的新对象 [英] How can we navigating through pages so we can create new object of a page from same page

查看:83
本文介绍了我们如何浏览页面,以便可以从同一页面创建页面的新对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何创建用于浏览页面的类似堆栈的结构,以便我们可以从同一页面创建页面的新对象, 这里我想从SuperPage转到SuperPage,但是角度路由不支持它,在IONIC3中,我们可以通过navCtrl的push方法非常轻松地实现它,但是我想要在ionic 4中在同一页面上导航(SuperPage),那么我们如何实现这个??

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)模态页面

您可以像模式页面一样调用页面,我们的模式页面将显示在超级页面上方,我们可以将信息传递给页面,现在我们可以像在ionic v3中一样访问此信息.

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页面,该页面在技术上类似于模式页面.

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

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

我认为您可以使用Modal

这篇关于我们如何浏览页面,以便可以从同一页面创建页面的新对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆