Navcontroller push error

Asked

Viewed 616 times

0

is giving error in the push =(( I am not able to make the home page call the Timeline page

    import { Component , ViewChild } from '@angular/core';
    import { NavController} from '@ionic/angular';
    import { TimelinePage } from "../timeline/timeline";
    @Component({
      selector: 'app-home',
      templateUrl: 'home.page.html',
      styleUrls: ['home.page.scss'],
    })
    export class HomePage {

     @ViewChild('Usuario') email;
     @ViewChild('password') senha;

     constructor(public NavCtlr : NavController){ }
     
     entrar(){

       if(this.email.value == "fernando" && this.senha.value == "123"){
 this.NavCtlr.push(TimelinePage);

       }else{

       }
     }
    }
<!-- begin snippet: js hide: false console: true babel: false -->

  • Edit the question and enter your code; not the screen print!

  • OK I’ll change ...

  • Welcome to Sopt. For a better answer, try to express yourself better. Where exactly does the error occur, what kind of error and its description? Add as much information as possible in the post.

  • in the log this spelled "Property 'push' do not exist on type 'Navcontroller'

1 answer

0


You are using version 4 of Ionic which no longer has the method push. To navigate between pages, you need to use the new method called navigateForward. Its use would be like this:

// O 'timelinePage' precisa estar definido no seu app-routing.module.ts
this.NavCtlr.navigateForward('timelinePage');

To learn more about the new navigation, I recommend this article (in English), access here.

Browser other questions tagged

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