I am currently learning Angular and encountering an issue while setting up routes in my Angular application. The error occurs in the app.module.ts file when trying to declare the routes service within RouterModule.forRoot(). I need assistance with determining what should be included in the parentheses of this method.
error: error TS2304: Cannot find name 'Routes'.RouterModule.forRoot(Routes)
route.service.ts:
import { Injectable } from '@angular/core';
import { Routes } from '@angular/router';
import { ParentComponent } from '../parent/parent.component';
import { from } from 'rxjs';
import { ChildComponent } from '../child/child.component';
const appRoutes:Routes=[
{path:"parent",component:ParentComponent},
{path:"child",component:ChildComponent}
]
@Injectable({
providedIn: 'root'
})
export class RoutesService {
constructor() { }
}
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
// import {MessageserviceService} from './services/messageservice.service'
import {MessageserviceService} from './services/messageservice.service';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ParentComponent } from './parent/parent.component';
import { ChildComponent } from './child/child.component';
import { RoutesService } from './services/routes.service';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
AppComponent,
ParentComponent,
ChildComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
RouterModule.forRoot(appRoutes) //i got error in this line,
],
providers: [MessageserviceService,RoutesService],
bootstrap: [AppComponent]
})
export class AppModule { }