Skip to content

Schematics: addRouteDeclarationToModule #15016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
israelpasos opened this issue Jul 8, 2019 · 1 comment · Fixed by #15022
Closed

Schematics: addRouteDeclarationToModule #15016

israelpasos opened this issue Jul 8, 2019 · 1 comment · Fixed by #15022

Comments

@israelpasos
Copy link

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

No

Description

addRouteDeclarationToModule in angular-cli/packages/schematics/angular/utility/ast-utils.ts. Adds the route literal within guard arrays.

Original Routes[]:

const routes: Routes = [{
      path: 'admin',
      loadChildren: () => import('src/app/bvs-ppa/admin/admin.module').then(m => m.AdminModule),
      canActivate: [AdminGuard],
      canActivateChild: [AdminGuard],
      canLoad: [AdminGuard]
    }];

After addRouteDeclarationToModule:

const routes: Routes = [{
      path: 'admin',
      loadChildren: () => import('src/app/bvs-ppa/admin/admin.module').then(m => m.AdminModule),
      canActivate: [AdminGuard],
      canActivateChild: [AdminGuard],
      canLoad: [, {
      path: 'technical',
      loadChildren: () => import('src/app/bvs-ppa/technical/technical.module').then(m => m.TechnicalModule),
      canActivate: [TechnicalGuard],
      canActivateChild: [TechnicalGuard],
      canLoad: [TechnicalGuard]
    }AdminGuard]
    }];

Expected:

const routes: Routes = [{
      path: 'admin',
      loadChildren: () => import('src/app/bvs-ppa/admin/admin.module').then(m => m.AdminModule),
      canActivate: [AdminGuard],
      canActivateChild: [AdminGuard],
      canLoad: [AdminGuard]
    },
    {
      path: 'technical',
      loadChildren: () => import('src/app/bvs-ppa/technical/technical.module').then(m => m.TechnicalModule),
      canActivate: [TechnicalGuard],
      canActivateChild: [TechnicalGuard],
      canLoad: [TechnicalGuard]
    }
  ];

🌍 Your Environment

Angular CLI: 8.0.6
Node: 10.15.3
OS: darwin x64
Angular: 8.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.800.6
@angular-devkit/build-angular 0.800.6
@angular-devkit/build-optimizer 0.800.6
@angular-devkit/build-webpack 0.800.6
@angular-devkit/core 8.0.6
@angular-devkit/schematics 8.0.6
@angular/cdk 8.0.1
@angular/cli 8.0.6
@angular/material 8.0.1
@ngtools/webpack 8.0.6
@schematics/angular 8.0.6
@schematics/update 0.800.6
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0

@ngbot ngbot bot modified the milestone: needsTriage Jul 9, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jul 9, 2019
@alan-agius4 alan-agius4 self-assigned this Jul 9, 2019
@alan-agius4 alan-agius4 modified the milestones: Backlog, 8.1.x Jul 9, 2019
kyliau pushed a commit that referenced this issue Jul 9, 2019
`findNodes` will continue looking for arrays recursively unless we specify that we specify that we want only the first array.

Routes array can contain nested arrays such as when specifying guards.

Fixes #15016
kyliau pushed a commit that referenced this issue Jul 9, 2019
`findNodes` will continue looking for arrays recursively unless we specify that we specify that we want only the first array.

Routes array can contain nested arrays such as when specifying guards.

Fixes #15016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants