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

96
Views
Angular routing displaying the same app.component.html

I'm currently using Angular version 13.

As stated by the official documentation, routing should be done by creating a component and routing it like this in the app-routing.module.ts

const routes: Routes = [
{ path: 'first-component', component: 
FirstComponent },
{ path: 'second-component', component: 
SecondComponent },
];

but doing so will render my app.comoponent.html file without actually changing anything. I can see that the url changed, but that's about it. Other newer sources consider doing something like

{
path:'mainpage',
loadChildren: () => import('./mainpage/mainpage.module').then(m 
=> m.MainpageModule)
}

and, as the solution above, does not work for me. I've also added the <router-outlet></router-outlet> directive, (which was actually already added) but nothing changed. What is currently happening? Thanks!

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

0

The RouterOutlet Acts as a placeholder that Angular dynamically fills based on the current router state so in most cases you'll probably have the <router-outlet></router-outlet> directive in your app.component.html. This element actually informs Angular to update the application view with the component for the selected route.

Each route in routes array is a JavaScript object which contains two properties. The first property is the path which defines the URL path for the route. The second one is the component which defines the component Angular should use for the corresponding path.

loadChildren is a different issue. By default, Angular NgModules are eagerly loaded, which means that as soon as the application loads, so does all of the NgModules, even if they are not immediately necessary. If you wish to use lazy loading for Angular modules, you can use the loadChildren (instead of component like in your first example) in your AppRoutingModule routes.

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!