Skip to content
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

Add option to generate a guard for CanDeactivate, CanActivateChild, CanLoad #13400

Closed
bastienmoulia opened this issue Jan 10, 2019 · 3 comments · Fixed by #13109
Closed

Add option to generate a guard for CanDeactivate, CanActivateChild, CanLoad #13400

bastienmoulia opened this issue Jan 10, 2019 · 3 comments · Fixed by #13109
Labels
area: schematics/angular feature Issue that requests a new feature
Milestone

Comments

@bastienmoulia
Copy link

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Command (mark with an x)

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

Desired functionality

Actually (7.2.0), when a guard is generated, it implements CanActivate.
I would like to see an option to generate a guard with CanDeactivate, CanActivateChild or CanLoad.

@alan-agius4
Copy link
Collaborator

There is a PR for this #13109

@okeefem2
Copy link
Contributor

okeefem2 commented Jan 10, 2019

Just as a note, CanDeactivate was not included in #13100 mainly because in order to implement that properly you need a component class. I have thought about a few ways of doing this but am not sure exactly which way the team would like to go with it. One potential way I see is that if CanDeactivate is selected, then the cli would prompt for a component to implement, and could either create if it doesn't exist or error.

Another more simple approach would be to scaffold the guard with CanDeactivate<> without a component and leave it to the developer to implement, but generating broken code doesn't seem like a great practice to me...

Or I guess it could be generated with any but that also smells a little bit...

Anyway I'd be happy to implement the solution if anyone has thoughts on it? @alan-agius4 @clydin

okeefem2 added a commit to okeefem2/angular-cli that referenced this issue Jan 10, 2019
okeefem2 added a commit to okeefem2/angular-cli that referenced this issue Jan 10, 2019
Adds support for the guard schematic to use multiselect for which interfaces the guard should implement.

Fixes angular#13400
okeefem2 added a commit to okeefem2/angular-cli that referenced this issue Jan 15, 2019
Adds support for the guard schematic to use multiselect for which interfaces the guard should implement.

Fixes angular#13400
okeefem2 added a commit to okeefem2/angular-cli that referenced this issue Jan 15, 2019
Adds support for the guard schematic to use multiselect for which interfaces the guard should implement.

Fixes angular#13400
kyliau pushed a commit that referenced this issue Jan 15, 2019
Adds support for the guard schematic to use multiselect for which interfaces the guard should implement.

Fixes #13400
@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.
Labels
area: schematics/angular feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants