Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

NgForm.reset() always set a null value if the NgModel has a converter #1587

Open
@anthony-foulfoin

Description

@anthony-foulfoin

Hi,

Given the following input in a form :

<input type="text" ng-model="customer.birthay" date-formatter>

And the following decorator :

@Decorator(selector: '[date-formatter]')
class DateFormatter implements AttachAware {

  NgModel model;

  DateFormatter(NgModel this.model) {
  }

  void attach() {
    model.converter = new DateConverter();
  }
}

class DateConverter implements NgModelConverter {

  DateFormat dateFormat = new DateFormat("d/M/y");

  @override
  parse(value) {
    return dateFormat.parse(value);
  }

  @override
  format(value) {
    return value == null ? null : dateFormat.format(value);
  }

}

The model is initialized with a value in the controller.
Then, I modify manually the input value, and I reset the form :

form.reset();

I expect the model to be reset to its initialized value, but instead the model value is set to null.
If I remove the converter in the decorator, everything works well, the model is correctly reset to its initial value after resetting the form.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions