ionic-team / angular-toolkit

Angular Schematics and Builders for `@ionic/angular` apps.
MIT License
69 stars 30 forks source link

ionic g page child doesn't update nearest routing module #118

Open hugoblanc opened 5 years ago

hugoblanc commented 5 years ago

Description: I'm generating module with --routing option. If I generate child page to this module, routing.module.ts is marked as updated but in fact it is not.

Steps to Reproduce:

ionic start errorgene blank cd errorgene ionic g module todos --routing ionic g page todos/todos-list

Output:

For the following command ionic g page todos/todos-list

CREATE src/app/todos/todos-list/todos-list.module.ts (559 bytes) CREATE src/app/todos/todos-list/todos-list.page.html (129 bytes) CREATE src/app/todos/todos-list/todos-list.page.spec.ts (713 bytes) CREATE src/app/todos/todos-list/todos-list.page.ts (271 bytes) CREATE src/app/todos/todos-list/todos-list.page.scss (0 bytes) UPDATE src/app/todos/todos-routing.module.ts (248 bytes) [OK] Generated page!

but todos-routing.module.ts is not updated

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

const routes: Routes = [];

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

My ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (C:\Users\hugob\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.1.2
   @angular-devkit/build-angular : 0.13.7
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.7
   @ionic/angular-toolkit        : 1.4.1

System:

   NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10
imhoffd commented 5 years ago

@hugoblanc Is app-routing.module.ts modified instead?

hugoblanc commented 5 years ago

Sorry for delay

nop, nothing has changed in app-routing.module.ts

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

const routes: Routes = [ { path: '', redirectTo: 'home', pathMatch: 'full' }, { path: 'home', loadChildren: './home/home.module#HomePageModule' }, ];

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

hersonls commented 2 years ago

@hugoblanc I'm having the same problem. I did some tests and I believe it's some parser validation, because when my array is empty it's not added, but when I put any object in the array, the path is added. For example:

Before:

Screen Shot 2021-11-28 at 11 38 55

ionic generate page profile/detail --route-path=detail

Screen Shot 2021-11-28 at 11 46 44

Nothing happen, but after adding this:

Screen Shot 2021-11-28 at 11 39 05

And executing again:

ionic generate page profile/detail --route-path=detail

Screen Shot 2021-11-28 at 11 42 41

And it's work. My module structure is:

Screen Shot 2021-11-28 at 11 45 24

I think it might help us find the problem.