Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
Angular component reloads when navigating

Routes for my Module:

const routes: Routes = [
  { path: ":level1/:level2/:level3", component: CategoriesComponent },
  { path: ":level1/:level2", component: CategoriesComponent},
  { path: ":level1", component: CategoriesComponent},
  { path: "", component: CategoriesComponent },
];

the Categories component Generates some links like so:

<a [routerLink]="['category1']" [relativeTo]="activatedRoute">My Link</a>

the ngOnInit & ngOnDestroy are called each time it navigates between those routes.

What I need is the component to stay mounted and not re-init each time.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to dive into a RouteReuseStrategy and create your custom strategy with saving touched pages Docs

about 4 years ago · Juan Pablo Isaza Report

0

RouteReuseStrategy allows you to tell Angular not to destroy a component, but in fact to save it for re-rendering at a later date. https://stackoverflow.com/a/41515648/15439733

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!