I am implementing router in Ionic 4, basically just want to navigate from one to another page.
I implemented the code as below:
import { Component } from '@angular/core';
import { NavController, LoadingController } from '@ionic/angular';
import { Route } from '@angular/router';
@Component({
selector: 'app-secure2fa',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
introFlag; any = false;
userName: String;
loading: any;
constructor(private route: Route)
{
}
goRegister() {
this.route.navigateByUrl('/secure-registration');
}
}
The secure-registration page is create using Ionic CLI command so it automatically get added to app-routing.module as below:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: '', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: 'location', loadChildren: './location/location.module#LocationPageModule' },
{ path: 'secure-registration', loadChildren: './secure-registration/secure-registration.module#SecureRegistrationPageModule' },
{ path: 'success-registration', loadChildren: './success-registration/success-registration.module#SuccessRegistrationPageModule' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}
The problem I got here is that navigateByUrl or even navigate is not found. Error as below:
Property 'navigateByUrl' does not exist on type 'Route'.
Anyone know if I have missed something here. I am using Ionic 4.
Thanks.