MCPcopy Create free account
hub / github.com/betsol/angular-input-modified / onModifiedStateChanged

Function onModifiedStateChanged

src/directive/form.js:86–107  ·  view source on GitHub ↗

* This universal function is called when child model or child form is modified * by the modified component itself. * It will update the corresponding tracking list, the number of modified components * and the form itself if required. * * @param {FormContr

(ctrl, list)

Source from the content-addressed store, hash-verified

84 * @param {FormController[]|NgModelController[]} list The tracking list of modified controllers (models or forms)
85 */
86 function onModifiedStateChanged (ctrl, list) {
87
88 var listIndex = list.indexOf(ctrl);
89 var presentInList = (-1 !== listIndex);
90
91 if (ctrl.modified && !presentInList) {
92
93 // Adding model to the internal list of modified models.
94 list.push(ctrl);
95
96 updateFormState();
97
98 } else if (!ctrl.modified && presentInList) {
99
100 // Removing model from the internal list of modified models.
101 list.splice(listIndex, 1);
102
103 updateFormState();
104
105 }
106
107 }
108
109 /**
110 * Updates form state and notifies it's parents.

Callers 1

formDirectiveFactoryFunction · 0.85

Calls 1

updateFormStateFunction · 0.85

Tested by

no test coverage detected