Skip to content

Add option to implement CanDeactivate interface while generating a guard #15668

@preethamvishy

Description

@preethamvishy

🚀 Feature request

Request to add option to implement CanDeactivate interface while generating a guard using ng generate.

Command (mark with an x)

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

Description

The CLI has a nice selection option and schematics to implement CanActivate, CanActivateChild, CanLoad interfaces while generating a new guard. While I understand that it is not as straightforward as the others, it would be nice to have the option to implement the CanDeactivate interface as well.

Describe the solution you'd like

It would be nice to have a flag to indicate the component for which we want to implement the CanDeactivate interface for while generating it. Generate the guard for the component and update the component to add a generic canDeactivate() method similar to how we auto-update a module when a new component is created under it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions