Routing in Angular

 Routing in Angular


Routing is used to define the navigation paths in an Angular application. Here is an example of routing in Angular:


import { NgModule } from '@angular/core';

import { RouterModule, Routes } from '@angular/router';

import { HomeComponent } from './home.component';

import { AboutComponent } from './about.component';


const routes: Routes = [

  { path: '', component: HomeComponent },

  { path: 'about', component: AboutComponent },

];


@NgModule({

  imports: [RouterModule.forRoot(routes)],

  exports: [RouterModule],

})

export class AppRoutingModule {}

This routing module defines two routes: one for the home page and one for the about page.

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...