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 · 2 comments

Comments

Projects
None yet
3 participants
@bastienmoulia
Copy link

bastienmoulia commented Jan 10, 2019

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

This comment has been minimized.

Copy link
Collaborator

alan-agius4 commented Jan 10, 2019

There is a PR for this #13109

@okeefem2

This comment has been minimized.

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

feat(@schematics/angular): Added multiselect guard implements option
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

feat(@schematics/angular): Added multiselect guard implements option
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

feat(@schematics/angular): Added multiselect guard implements option
Adds support for the guard schematic to use multiselect for which interfaces the guard should implement.

Fixes angular#13400

kyliau added a commit that referenced this issue Jan 15, 2019

feat(@schematics/angular): Added multiselect guard implements option
Adds support for the guard schematic to use multiselect for which interfaces the guard should implement.

Fixes #13400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment