I'm migratin app from Angular 1.2 to 1.3. And I'm facing to problem with
different behaviour of removeControll and addControll functions.
I have a directive like this, which escaping registered elements in form
(don't ask why, We just need it).
<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]);
}
And Angular 1.2 will give the wanted result {"es\\.caped":{}}. But 1.3 will
give me old value {"es.caped":{}}
For more info, how it works see:
1.2 version - Plunker 1.2 version
<https://plnkr.co/edit/LfFKt2rppP3RuGRorweL>
1.3 version - Plunker 1.3 version
<https://plnkr.co/edit/GcU72lmd2RZxsrXNCucD>
Plunker will print result form as a json (1.3 output is more bigger, but
you can find the values).
I tried to search in docs and for versions 1.2 and 1.3 there are almost
nothing, but for 1.5 I found:
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
<https://code.angularjs.org/1.5.2/docs/api/ng/type/form.FormController>
And I already spent many hours to solve this problem, but with no success.
I don't know how to propagate changes. I will be glad for any help.
Note: I tried it also with angular 1.4 and 1.5. And it has same behaviour
as 1.3. My final state of migration is 1.5, but I'm following migration
guide version by version.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.