Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RouterModule component, loadChildren, redirectTo

Tags:

angular

Could anybody tell me the difference between component, loadChildren, redirectTo?

export const ROUTES: Routes = [{
   path: '', redirectTo: 'signin', pathMatch: 'full'
  }, {
    path: 'app',   loadChildren: () => System.import('./layout/layout.module')
  }, {
    path: 'login', loadChildren: () => System.import('./login/login.module')
  }, {
    path: 'signin', loadChildren: () => System.import('./signin/signin.module')
  }, {
    path: 'error', component: ErrorComponent
  }, {
    path: '**',    component: ErrorComponent
  }
];
like image 864
Jordi Avatar asked Oct 17 '22 20:10

Jordi


1 Answers

Apparently, the documentation can do it. Check the router page.

Otherwise, component is to directly link a path to a component, loadChildren is used to load asynchronous component and redirectTo is simply to redirect to another route.

like image 93
LoïcR Avatar answered Nov 18 '22 10:11

LoïcR