Angular routing vs Ionic routing

Viewed 12231

I'm new to ionic2. There is something weird in it's routing compared to pure angular routing. In Angular:

const appRoutes: Routes = [
  { path: 'crisis-center', component: CrisisListComponent },
  { path: 'hero/:id',      component: HeroDetailComponent },
  {
    path: 'heroes',
    component: HeroListComponent,
    data: { title: 'Heroes List' }
  },
  { path: '',
    redirectTo: '/heroes',
    pathMatch: 'full'
  },
  { path: '**', component: PageNotFoundComponent }
];

@NgModule({
imports: [
  RouterModule.forRoot(appRoutes)
  // other imports here
],

We pass a constant with type of Routes.

In Ionic (sidemenu starter) they pass a component to forRoot function.

import { MyApp } from './app.component';
imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
],

Any idea?

2 Answers

In ionic, we push a view screen from another views

But in angular it is predefined routes mapping that if you go to this route i.e. app/login you will be redirected to login route that is bind with loginComponent

Related