0

I've been using Angular for a long time I know how routes work but I wanted to try something new for me using lazy loading, as you can see in my I'm trying to navigate from one point to another but something is wrong or maybe not possible.

thanks.

ts.file

this.router.navigate(['../delta']);

app.routing.module.ts // root file

const routes: Routes = [
 {
  path:delta,
  loadChildren: () => import('./delta/delta.module').then(m => m.DeltaModule.);
 }
]

is it possible to navigate like this?

3
  • 2
    May only be in the sample code, but you have a quote missing in your import statement. Is that the problem? Commented Aug 9, 2021 at 15:16
  • @MikeHanson is juste sample code Commented Aug 9, 2021 at 15:17
  • 2
    I've been using angular for a long time, but never seen the ../ used in routes. I suspect it won't match the delta route you defined. Certainly the structure of the route looks fine to me if it is propertly formed with quotes and the dot at the end of m.DeltaModule is removed. Commented Aug 9, 2021 at 15:21

1 Answer 1

3

If you want to use that relative syntax, then you should do something like this:

constructor(private route:ActivatedRoute,private router:Router){}

...

this.router.navigate(['../delta'], { relativeTo: this.route });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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