Skip to content

Angular Forms: Include control property to detect if the current control value is the same as the one received during component init #10468

@PEsteves8

Description

@PEsteves8

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

[x ] feature request

Current behavior

In the new forms module, the property 'pristine' of a control turns to false if the value in that control changes. However, if after changing the value, the user returns it to the original one, the pristine property remains false.

Example:
A user clicks 'Edit Email'. The form input for the email starts with the value of the current email, already inserted. The user deletes one letter. The "Save" button, changes from disabled to enabled. The user puts back the same letter. Ideally the "Save" button should become disabled again, since there are no changes to be made. There are reasons for 'pristine' to not go back, however what about having another property that checks if the current value is different from the original one?

Expected/desired behavior
There should be a way to detect if there the current value in an input control is different from the one that received with the ngModel binding when the component was initialized, even if the value was changed (and then changed back to the original one).

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

Adjusting form css classes in a form according to the current input values vs the ones that were filled when the component was initialized. (ie. Independently of a form control being touched, did the value change from the original?)

  • Angular version: 2.0.0-rc.4
    "@angular/forms": "0.2.0",
  • Language: [all | TypeScript 1.8.1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions