Angular2 (beta3) "expression changed after checking it" when updating form values

This is a kind of continuation of my previous post on nested forms in Angular2 (beta 3 with TS) ( Angular2 beta: forms-based nested parent / child components and parent confirmation ), but I'm posting a new question as it relates to a different type of problem.

You can find a reproduction of the problem described here at http://plnkr.co/edit/iCmmy9at2wF5qY0P6VmV . In short, in this fake scenario, I have a component representing one word from an imaginary dictionary and another child component used to represent each meaning for that word; Thus, there is a 1-to-many relationship between the parent component and its children. Both have a form-based template built using the form builder. The child pattern is inside NgForwhere I attach every meaning from the parent (= word) model. Thus, all the properties of each word meaning are automatically associated with the word model.

Some of these properties have several attached validators (both standard and standard). My problem is that when I programmatically install the word model from the parent component (which also involves setting the value of the form controls), this seems to cause some race conditions during the validation process, which raises a few exceptions like EXCLUSION: Expression '! DefinitionCtl.valid 'has changed after checking it. Previous value: "true". Current value: "false" , which blocks further code execution.

AFAIK, the only information that seems to be related to this problem is here:

, , , ( ), , , . - ?

+4
2

Angular2 dev:

import {bootstrap} from 'angular2/platform/browser';
import {App} from './app';
import {enableProdMode} from 'angular2/core';

enableProdMode();

bootstrap(App, [])
  .catch(err => console.error(err));

. GΓΌnter:

0

. https://github.com/angular/angular/issues/6005. ( ).

  • Angular - https://github.com/GeoscienceAustralia/GNSS-Site-Manager, , ngOnInit(). ngIf
  • ngOnInit() theModelForm.patchValue(data)
  • , . , DOM , ngOnInit(), , . patchValue(), .
    • patchValue() a this._changeDetectionRef.detectChanges();. ngIf [hidden], DOM . - , DOM ( , , ).
    • patchValue() ( setValue(), 1:1) , , ngOnInit().

(22/3/17).

+1

Source: https://habr.com/ru/post/1627335/


All Articles