Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

How to reset form? #39

Closed
Closed

Description

@iltera

I'm trying to reset form to it's pristine state, but cannot succeed. I looked for a working example here, but couldn't find that either. I am changing all the input values to empty text (""), and then calling myform.$setPristine(); I think that is the way to do it. But the $setPrisitine() doesn't seem to do anything.

Can anyone guide me where to check or what could be the issue?

Activity

  1. iltera commented on Jun 15, 2015

    @iltera
    Author

    Added $setUntounched() and I guess it works now :)

  2. ghiscoding commented on Jun 15, 2015

    @ghiscoding
    Owner

    Hello, yes I use the $touched especially for showing errors on an empty form. For example, looking at this functionality on the Wiki - Pre-Validate Form on Page Load is done using the $touched as you found out.

    I could had a comment in the Wiki documentation if you want, but yes that is the correct way of resetting a form.

    Thanks for using it ;)

  3. ghiscoding commented on Jun 15, 2015

    @ghiscoding
    Owner

    Added a Wiki - Reset Form, that should explain it well. Let me know if you have other comments about it. :)

    Actually I did not try it, but does it reset the $touched on each input element as well? I hope it does, else I will have to make another function in the Service.

  4. ghiscoding commented on Jun 16, 2015

    @ghiscoding
    Owner

    Ok I tried it and that is actually not enough, doing the $setUntouched() and $setPristine() does not remove the errors displayed (if any).

    I will re-open this issue and add a new function in the Service, should be done in the next couple days. Since I also add Protractor tests, it's a bit longer to do both.

    Thanks for the feedback

  5. added a commit that references this issue on Jun 21, 2015
  6. ghiscoding commented on Jun 21, 2015

    @ghiscoding
    Owner

    This functionality was added in v1.3.31, there is a lot more options than I imagined at first. So the possible options you can pass the function should cover all cases.

    Make sure to update to latest v1.3.31 to see the changes
    Enjoy ;)

  7. iltera commented on Jun 23, 2015

    @iltera
    Author

    @ghiscoding, thank you for taking time to take a look at this issue. I will try the new version when I'll have time. If anything comes up, will report back here. Thanks again! :)

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions