How do you route in Ionic 3 (deep linkings)?

Asked

Viewed 319 times

1

I would like to know how I do that by clicking a custom button, open my page with the route in the browser?

Example in the view:

<button (click)="sairDaPagina()" class="btn btn-default">Sair</button>

My class:

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

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {
  }

  sairDaPagina() {
    this.navCtrl.push('SairPage');
  }
}  

The app.compoment.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
import { EsqueciMinhaSenhaPage } from '../pages/esqueci-minha-senha/esqueci-minha-senha';
import { SairPage } from '../pages/sair/sair';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = HomePage;

  pages: Array<{title:string, component: any}>;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {

    platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();
    });

    this.pages = [
      {title:"Página inicial", component:HomePage},
      {title:"Esqueci minha senha", component:EsqueciMinhaSenhaPage},
      {title:"Sair", component:SairPage}
    ];
}
}

Obs: I’m not even able to display the URL

In order to access, I had to add to my class:

import { SairPage } from '../../pages/sair/sair';

And change that:

 sairDaPagina() {
    this.navCtrl.push(SairPage);
 }

I just haven’t been able to display the URL yet.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.