Hello fellow programmer friends,
Need help for the error in the title.
This is my routing module code
app-routing.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {RouterModule,Routes} from '@angular/router';
import { routes } from './routes';
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(routes)
],
declarations: [RouterModule]
})
export class AppRoutingModule { }
I tried removing RouterModule from the declarations array as well but not getting rectified.
Please help.
In declarations you can not add any Modules. As the error says: only Components,Pipes or Directives are allowed to be declared in declarations array
Understood what mistake I did.
I placed the RouterModule in declarations instead of exports.
This thread may assist future learners who make the same mistake like me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With