2016-03-22 1 views
0

Ich bin Migratin App von Angular 1.2 zu 1.3. Und ich habe Probleme mit dem Verhalten der Funktionen removeControl1 und addControl1.Angular 1.2 zu 1.3 (oder neuer) Formular removeControll und addControll Probleme

Ich habe eine Direktive wie diese, die registrierte Elemente in Form entkommen (fragen Sie nicht, warum, wir brauchen es nur).

<div name="es.caped" ng-model="es.caped" esc-dir></div>  

link: function link($scope, $element, $attrs, $ctrl) { 
     var nameAttr = $attrs.name.replace(/([ #;?&,.+*~\':"!^$[\]()=>|\/@\{\}])/g, '\\$1'); 
     $ctrl[1].$removeControl($ctrl[0]); 
     $ctrl[0].$name = nameAttr; 
     $ctrl[1].$addControl($ctrl[0]); 
    } 

Und Angular 1.2 wird das gewünschte Ergebnis {"es\\.caped":{}} geben. Aber 1.3 gibt mir Altwert {"es.caped":{}}

Für mehr Informationen, wie man es sehen funktioniert:
Version 1.2 - Plunker 1.2 version
Version 1.3 - Plunker 1.3 version
Plunker wird Ergebnis Form als json (1.3 Ausgabe drucken ist größer, aber Sie können die Werte finden).

Ich habe versucht, in Dokumenten und für die Versionen 1.2 und 1.3 gibt es fast nichts, aber für 1,5 Ich fand zu suchen:

Note that the current state of the control will not be reflected on the new parent form. This is not an issue with normal use, as freshly compiled and linked controls are in a $pristine state. However, if the method is used programmatically, for example by adding dynamically created controls, or controls that have been previously removed without destroying their corresponding DOM element, it's the developers responsibility to make sure the current state propagates to the parent form

Und ich bereits viele Stunden zu lösen dieses Problem, aber mit nicht ausgegeben Erfolg. Ich weiß nicht, wie man Änderungen propagiert. Ich werde mich für jede Hilfe freuen.

Hinweis: Ich habe es auch mit eckigen 1.4 und 1.5 versucht. Und es hat das gleiche Verhalten wie 1.3. Mein endgültiger Migrationsstatus ist 1,5, aber ich befolge den Migrationsführer Version für Version.

Antwort

0

Problem kann damit gelöst werden. Es ändert den Namen des Elements und spiegelt es im Controller wider.

link: function link($scope, $element, $attrs, $ctrl) { 
     var nameAttr = $attrs.name.replace(/([ #;?&,.+*~\':"!^$[\]()=>|\/@\{\}])/g, '\\$1'); 
     $attrs.name = nameAttr ; 
}