2

I have a medium size Angular App. Which is taking quite a lot of time in loading. Thus I decided to use Lazy Loading. I have a FeedbackModule which is lazy loaded. It looks like this:

Feedback Route:

export const FEEDBACK_ROUTES: Routes = [

{ path : '' , component : FeedbackComponent},
{ path : 'prebilling' , component : PrebillingComponent},
{ path : 'postbilling/login' , component : PostbillingComponentLogin},
{ path : 'postbilling/rating/:mid/:return/:mtid' , component : PostbillingRatingComponent},
{ path : 'prebilling/rating/:mid/:type/:mtid/:mcnt/:mebid' , component : PrebillingRatingComponent},
{ path : 'prebilling/rating' , component : PrebillingRatingComponent},
{ path : 'postbilling/rating/:id' , component : PostbillingRatingComponent},
{ path : 'prebilling/rating/:mid/:type/:mtid' , component : PrebillingRatingComponent},
{ path : 'thanks/:id' , component : ThankYouComponent}
];

Feedback Module:

@NgModule({
declarations: [
    PostbillingComponentLogin,
    PrebillingComponent,
    PrebillingRatingComponent,
    PostbillingRatingComponent,
    ThankYouComponent,
    FeedbackComponent,
    PostbillingForgotPassComponentLogin

],
imports: [
    CommonModule,
    CommonCustomModule,
    FormsModule,
    RouterModule.forChild(FEEDBACK_ROUTES)
],
exports:[ RouterModule]
})

export class FeedbackModule {
}

App.route.ts:

export const ROUTES : Routes = [
...COMMON_ROUTES,
{ path:'feedback', loadChildren: './feedBack/feedback.module#FeedbackModule'}
]

Now when I got for path /feedback Feedback component is loaded. But when I for /feedback/prebilling or any other path it still loads FeedbackComponent. Thanks in advance !

1
  • Did you try using the pathMatch: full option ? Commented Apr 19, 2019 at 9:33

2 Answers 2

3

Your code seems ok to me but you may try adding pathMatch: full

{ path : '' , component : FeedbackComponent, pathMatch: 'full' }

Let me know if it works for you...

Sign up to request clarification or add additional context in comments.

1 Comment

Always happy to help :)
1

This is because you are not targeting other routes as a child route of your lazy loaded module

const ROUTES: Routes = [ { path: '', component: OrgComponent, children: [ { path: 'intro', loadChildren: '../+intro/intro.module#IntroModule' }, { path: 'recent', component: RecentComponent }, ] } ]

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.