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

Event emitter for reset on forms #10999

Closed
cur3n4 opened this issue Aug 23, 2016 · 8 comments
Closed

Event emitter for reset on forms #10999

cur3n4 opened this issue Aug 23, 2016 · 8 comments
Labels
area: forms feature Issue that requests a new feature

Comments

@cur3n4
Copy link

cur3n4 commented Aug 23, 2016

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
With forms, one can subscribe to ngSubmit and be able to perform actions as a result of that.
There is no equivalent when resetting a form.

Expected/desired behavior
It would be very handy to have an ngReset EventEmitter which could notify subscribers of the act of resetting a form.

Reproduction of the problem

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 2.0.0-rc.5
  • Browser: all
  • Language: TypeScript X.X
@zoechi
Copy link
Contributor

zoechi commented Aug 23, 2016

How do you reset a form. If you reset the form imperatively you can notify yourself. If you use a reset button, this also emits an event.
Can you please elaborate a bit more on a use case where this would be useful? Ideally a Plunker that demonstrates where not having this event is a disadvantage?

@cur3n4
Copy link
Author

cur3n4 commented Aug 23, 2016

My specific use case is a directive which displays error for controls under configurable conditions (i.e. control has focus, control touched, form touched, form submitted, etc). When the form is reset I would like these directives to act accordingly (for example to not display certain errors).
I could certainly notify myself but it feels like a useful addition, and it makes sense to me to be in the framework: in the same way we have ngSubmit for onSubmit, we would have ngReset for onReset.

@kara kara added feature Issue that requests a new feature area: forms labels Aug 23, 2016
@mvar
Copy link

mvar commented Sep 28, 2016

+1 for such feature.

@kara
Copy link
Contributor

kara commented Oct 12, 2016

Given that you can already listen to the reset event or notify yourself, I'm inclined to think this isn't necessary. ngSubmit has extra value in that it allows the form directive's "submitted" state to be updated, but reset has no parallel state to set. I'd prefer not to add to the API surface unless it's really necessary. If more use cases come up for this in the future, we may reconsider, but closing for now.

@kara kara closed this as completed Oct 12, 2016
@mvar
Copy link

mvar commented Oct 13, 2016

@kara could you give a quick example on how to catch form event (e.g., reset) myself?

@zoechi
Copy link
Contributor

zoechi commented Oct 13, 2016

@mvar GitHub issues are for bug reports and feature requests.
For support questions please use other channels like the ones listed in CONTRIBUTING - Got a Question or Problem?

@zoechi
Copy link
Contributor

zoechi commented Oct 13, 2016

There are quite a lot of people nice enough to provide support - on the appropriate channels.

@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 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: forms feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

4 participants