How to add default route /PartDetails to localhost:4200 when site open to first site angular 7 ?

44 views
Skip to first unread message

ahmed elbarbary

unread,
Dec 19, 2019, 9:35:22 PM12/19/19
to Angular and AngularJS discussion
I work on angular 7  I need to make default routing for my web app
I need to to make default routing to my web app
Now on my web app when open on first time it  show like that
localhost:4200
I need to set default routing to open for first time as below 
localhost:4200/PartDetails


my  app-routing.module.ts


import { QualificationsComponent } from './Pages/qualifications/qualifications.component';
import { FamilyComponent } from './Pages/family/family.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { OverviewComponent } from './Pages/overview/overview.component';
import { ManufacturingComponent } from './Pages/manufacturing/manufacturing.component';
import { PackageComponent } from './Pages/package/package.component';
import { ParametricComponent } from './Pages/parametric/parametric.component';


const routes: Routes = [
 
{ path: '', component: OverviewComponent },
 
{ path: 'overview', component: OverviewComponent },
 
{ path: 'family', component: FamilyComponent },
 
{path:'manufacturing',component:ManufacturingComponent},
 
{path:'package',component:PackageComponent},
 
{path:'parametric',component:ParametricComponent},
 
{path:'qualifications',component:QualificationsComponent},
];


@NgModule({
  imports
: [RouterModule.forRoot(routes)],
  exports
: [RouterModule]
})
export class AppRoutingModule { }


How to do default routing 

Olaleye Israel

unread,
Dec 19, 2019, 10:15:54 PM12/19/19
to Angular and AngularJS discussion
simple,
{
   path: ' ',
   redirectTo: 'PartDetails',
   ...

ahmed elbarbary

unread,
Dec 20, 2019, 10:05:39 AM12/20/19
to Angular and AngularJS discussion
thank you for repl
PartDetails is name of route 
PartDetails is not component 
it is name 
so please 
How to redirect name is not component 
i try add
path: '' , redirectTo: '/PartDetails'}
it not working
How to solve this problem
Are angular not support routing to alias name
or must use component name
please help me

Olaleye Israel

unread,
Dec 21, 2019, 4:55:47 AM12/21/19
to ang...@googlegroups.com
hello,
...

const routes: Routes = [
   {
      path: ' ',
      redirectTo: '/PartDetails' // forward slash at beginning for absolute path and no slash for relative path
   },
   {
       path: 'PartDetails',
      component: PartDetailsComponent // must have a component to render when this path is reached...
   }
];
...

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/0a3ea202-a993-43d4-aa95-a63a6eee8c7c%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages