Skip to content

Generate module command adds route path to wrong line #15117

Closed
@mehmet-erim

Description

@mehmet-erim

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

ng generate module ranking --route ranking --module app.module command is working very well. But if there is a data property to routes in app-routing.module. The command add route path to wrong line.

🔬 Minimal Reproduction

ng new example-app --routing
ng generate module ranking --route ranking --module app.module

Add data property to ranking route, then my app-routing.module.ts like below

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
  {
    path: 'ranking',
    loadChildren: () => import('./ranking/ranking.module').then(m => m.RankingModule),
    data: { path: 'test', name: 'Test' },
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}

After, run the following command
ng generate module home --route home --module app.module

It adds my home route path to the wrong line like below:

const routes: Routes = [
  {
    path: 'ranking',
    loadChildren: () => import('./ranking/ranking.module').then(m => m.RankingModule),
    data: { path: 'test', name: 'Test' },
    { path: 'home', loadChildren: () => import('./home/home.module').then(m => m.HomeModule) },
  },
];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions