// app.component.ts
import { Component } from '@angular/core';
import { RouterModule, RouterOutlet, Routes } from '@angular/router';
import { CarComponent } from './components/car/car.component';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ContactsComponent } from './components/contacts/contacts.component';
const appRoutes: Routes = [
{ path: '', component: CarComponent },
{ path: 'contacts', component: ContactsComponent },
];
@Component({
selector: 'app-root',
standalone: true,
imports: [
RouterOutlet,
CarComponent,
CommonModule,
FormsModule,
RouterModule.forRoot(appRoutes),
],
templateUrl: './app.component.html',
styleUrl: './app.component.css',
})
export class AppComponent {
// title = 'angular-test';
}
// app.component.html
<router-outlet></router-outlet>
Ошибка -
X [ERROR] TS2322: Type 'ModuleWithProviders<RouterModule>' is not assignable to type 'readonly any[] | Type<any>'. [plugin angular-compiler]
src/app/app.component.ts:21:4:
21 │ RouterModule.forRoot(appRoutes),
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~