I've been working on setting up routing in Angular and encountered an issue with the error message:
Cannot read property 'forRoot' of undefined
Here is my app.routes.ts file:
import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from '../../components/login/login.component';
import { SignupComponent } from '../../components/signup/signup.component';
import { ResourcesComponent } from '../../components/resources/resources.component';
import { MyApp } from './app.component';
const routes: Routes=[
{path:'',component:MyApp},
{path:'login',component:LoginComponent},
{path:'signup', component:SignupComponent},
{path:'resources',component:ResourcesComponent},
];
export const routing=RouterModule.forRoot(routes);
In my app.module.ts file:
import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MyApp } from './app.component';
import { LoginComponent } from '../../components/login/login.component';
import { SignupComponent } from '../../components/signup/signup.component';
import { ResourcesComponent } from '../../components/resources/resources.component';
import { NavbarComponent } from '../../components/navbar/navbar.component';
import { RouterModule, Routes } from '@angular/router';
import { routes } from './app.routes';
@NgModule({
declarations:[
MyApp,
LoginComponent,
SignupComponent,
ResourcesComponent,
NavbarComponent
],
entryComponents: [MyApp],
imports:[BrowserModule,RouterModule.forRoot(routes)],
bootstrap: [MyApp]
})
export class AppModule {}
Unfortunately, I'm receiving errors related to RouterModule and routes: @angular/router/index has no exported member 'RouterModule' and 'Routes'