Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Add option to write invalid $modelValues to scope #8290

Closed
@Narretz

Description

@Narretz

Since the validation refactoring, theoretically all invalid models appear in the input even if invalid. It's however not possible to write an invalid $modelValue to the scope. The $validators now actively set $modelValue to undefined when it is invalid, meaning that users cannot use the previous workarounds for this behavior. They now only have $$invalidModelValue to get the raw value, but that is undocumented and quasi-private. Additionally, with $validators, it is not possible anymore to use a $parser to set the model even if invalid (another common workaround)

I propose we use ng-model-options to make it possible to write the parsed $modelValue to scope even if invalid.

Why is this needed?

  1. Server-side validation with using $setValidity manually is broken (see $setValidity somehow breaks model binding in 1.3.0 Beta 12 and after #8080 (comment))
  2. Keeping input regardless of validity (see input not showing invalid model values #1412 (comment))
  3. Displaying invalid models (from DB etc.): It currently displays the invalid model in the input, but at the same time resets the model to undefined (see http://plnkr.co/edit/Fapn7ePUhajjGNsjwIlg?p=preview)
  4. All common workarounds for this are broken in 1.3

/cc @matsko @shahata @petebacondarwin @caitp

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions