Navbar in Angular not loading pages

2 days ago 6
ARTICLE AD BOX

Make sure you have configured base-href in index.html

<head> <meta charset="utf-8" /> <title>Catbee Monaco Editor</title> <base href="/" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head>

Validate that you have provided, provideRouter(routes), in the bootstrapApplication's providers array.

import { provideRouter } from '@angular/router'; export const routes = [ // routes here! ] bootstrapApplication(AppComponent, { providers: [ ... provideRouter(routes), ... ], }).catch((err) => console.error(err));

Ensure you have imported RouterLink and RouterLinkActive into the imports array of the nav component.

@Component({ selector: 'app-navbar', imports: [RouterOutlet, RouterLink], // imports are mandatory! templateUrl: './nav.html', styleUrl: './nav.css' }) export class Navbar { }

Finally ensure you have router-outlet added to the bottom of app.html.

<!-- app content here! --> <router-outlet/>
Read Entire Article