Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routing Error When Updating to Angular version 15

Object literal may only specify known properties, and 'text' does not exist in type 'Route'.

Object literal routing error

src/app/app-routing.module.ts

    const routes: Routes = [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'detail/:id', component: HeroDetailComponent },
      { path: "dashboard", component: DashboardComponent, text: "Dashboard" },
      { path: "heroes", component: HeroesComponent, text: "Heroes" },
    ];

error showing inline with VSCode Intellisense

This happened when I ran the update command to get onto Angular v15: ng update @angular/core@15 @angular/cli@15.

like image 609
AlyssaNicoll Avatar asked Dec 06 '25 04:12

AlyssaNicoll


1 Answers

I fixed it after seeing this in the breaking changes: https://angular.io/guide/update-to-version-15#the-title-property-is-required-on-activatedroutesnapshot

Changing text to title seemed to get rid of the error.

src/app/app-routing.module.ts [old]

    const routes: Routes = [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'detail/:id', component: HeroDetailComponent },
      { path: "dashboard", component: DashboardComponent, text: "Dashboard" },
      { path: "heroes", component: HeroesComponent, text: "Heroes" },
    ];

src/app/app-routing.module.ts [new]

    const routes: Routes = [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'detail/:id', component: HeroDetailComponent },
      { path: "dashboard", component: DashboardComponent, title: "Dashboard" },
      { path: "heroes", component: HeroesComponent, title: "Heroes" },
    ];
like image 96
AlyssaNicoll Avatar answered Dec 08 '25 19:12

AlyssaNicoll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!