0

I have a sidebar in my page with certain options, I want to get redirected in a new page when the options are clicked.

I have an option called 'Pricing Details' when I click it a new page should open with /pricing added to the end of the base the URL. Although, the URL is getting updated, the new page is not opening.

This is my app.module.ts

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

const routes: Routes = [{ path: 'pricing', component: PricingComponent}];

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

This is HTML part with the Pricing Section

<li class="sub-menu" name="idk">
    <a routerLink='/pricing'>
      <span>Pricing Details</span>
    </a>
</li>

This is my app.module.ts

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

    import { AppRoutingModule } from './app-routing.module';
    import { AppComponent } from './app.component';
    import { SidebarComponent } from './sidebar/sidebar.component';
    import { NavbarComponent } from './navbar/navbar.component';
    import { HomeComponent } from './home/home.component';
    import { PricingComponent } from './pricing/pricing.component';
    import { EstimateComponent } from './estimate/estimate.component';
    import { AccountComponent } from './account/account.component';

    @NgModule({
      declarations: [
        AppComponent,
        SidebarComponent,
        NavbarComponent,
        HomeComponent,
        PricingComponent,
        EstimateComponent,
        AccountComponent
      ],
      imports: [
        BrowserModule,
        AppRoutingModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

When I click on pricing details, the URL is updating, but it's staying on the same page.

enter image description here

1 Answers1

1

Make sure you have included <router-outlet></router-outlet> in AppComponent html template

Chenna
  • 2,383
  • 3
  • 20
  • 36