0

So I try to navigate to other page, but nothing happening... Can anybody help me, to solve my problem ? What do I do wrong ?

My app.component.html look like:

<a routerLink="/about" routerLinkActive="active">About</a>
<router-outlet></router-outlet>

My app-routing-module.ts

import { AboutComponent } from './about/about.component';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  { path: 'about', component: AboutComponent }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: []
})
export class AppRoutingModule { }

My app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AboutComponent } from './about/about.component';
import { LoginComponent } from './login/login.component';


@NgModule({
  declarations: [
    AppComponent,
    AboutComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,

    ],
      providers: [],
      bootstrap: [AppComponent]
})
export class AppModule { }

I expect it to navigate to the corresponding route when I click on it

Xe1a
  • 3
  • 6

1 Answers1

2

try [routerLink]="['/about']"

tony
  • 834
  • 5
  • 10