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

Feat: parse / format / validation for ngModel collection values #12905

Closed

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Sep 21, 2015

Depends on #12783
This change has two goals:

  1. introduce a way to specify that ngModel handles a collection instead of a single value
  2. introduce support for parsing, formatting and validating (pfv) single collection items instead of the whole collection via a new API.
  3. make ngList use $isCollection to enable view updates when part of the model collection changes

Regarding 1), it's currently a simple property $isCollection on the modelCtrl that does two things: it activates the deepWatch behavior, and informs the pfv that the model is a collection.
TODO: move $isCollection to ngModelOptions?

Regarding 2). There's a new API for pfv that makes it possible to decide if the whole model or single collection items are handled. These are simple classes that are added to the $parsers, $formatters pipelines respectively $validators collection as before. Legacy pfv continue to receive the whole collection as values for backward compat.
TODO: expose NgModelTransform, NgModelValidator to the public

…essing collection items

Legacy p/f/v will receive the whole collection as argument, the new API
allows to specify if collection items are handled.
When the controller handles a collection it will set a special
property $$viewValueCollection that is set to the collection that is
returned by the first parser / last formatter, respectively. If there's
no parser / formatter, assume that the viewValue / modelValue is already
a collection. $$viewValueCollection represents the viewValue (which is usually a string), as a collection of single values, so validators that handle collection items can validate the viewValue of collection items.
@Narretz Narretz added this to the 1.5.x - migration-facilitation milestone Sep 21, 2015
@Narretz Narretz force-pushed the feat-model-collection-validation branch from b7eb0a5 to ae7b629 Compare September 21, 2015 19:01
@petebacondarwin petebacondarwin modified the milestones: 1.5.x - migration-facilitation, 1.6.x Nov 23, 2015
@Narretz Narretz modified the milestones: 1.6.x, Ice Box Nov 30, 2017
@Narretz Narretz closed this Mar 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants