Last active
December 13, 2018 18:52
-
-
Save xantiagoma/aece31e5a3038529cb84ea36b93f9130 to your computer and use it in GitHub Desktop.
While debug copy & paste functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select <gh-event> in Elements panel then in | |
// Console paste: | |
var eventForm = ng.probe($0).componentInstance.eventForm; | |
var FormArray = eventForm.constructor; | |
var FormGroup = eventForm.controls[0].constructor; | |
var findInvalidControlsRecursive = function findInvalidControlsRecursive(formToInvestigate) { | |
var invalidControls = []; | |
var recursiveFunc = function (form) { | |
Object.keys(form.controls).forEach(function (field) { | |
var control = form.get(field); | |
if (control.invalid) | |
invalidControls.push(field); | |
if (control instanceof FormGroup) { | |
recursiveFunc(control); | |
} | |
else if (control instanceof FormArray) { | |
recursiveFunc(control); | |
} | |
}); | |
}; | |
recursiveFunc(formToInvestigate); | |
return invalidControls; | |
}; | |
findInvalidControlsRecursive(eventForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment