Ionic navigate from one page to another, not working

553 views Asked by At

I'm having the following issue. I created an ionic projekt and generated a Homepage and a Register page. When I try to do the navigation from home to register, and when I click on the register button it brings me back to homepage, instead of going to register page. I don't know what I'm doing wrong, I read bassicaly everything I found, and it seems that I am doing everything correctly. I also tried with a href, but I still have the same problem.

Here is the button that i generated in my Homepage html:

   <ion-button (click)="register()">Register</ion-button>

Here is the Funktion in ts-file:

      register() {
      this.navctrl.navigateForward(['register']);
      }

And here is the auto generated path in the routing page:

{ path: 'register', loadChildren: './register/.module#RegisterPageModule' },
1

There are 1 answers

0
xFGerald On

Here is the syntax :

import { Router } from '@angular/router';

...
constructor(private router: Router){}
 register() {
      this.router.navigate(['/register']);
      }

Here you go.