Created
March 26, 2019 10:20
-
-
Save dancornilov/7b58f51d72b43d8d70f9ad9a80d52153 to your computer and use it in GitHub Desktop.
Get FormControl name
This file contains 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
/** | |
* Extract control name from formGroup | |
* | |
* @return string | |
*/ | |
public getControlName(): string { | |
let controlName = null; | |
const parent = this.control['parent']; | |
if (parent instanceof FormGroup) { | |
for (const name in parent.controls) { | |
if (this.control === parent.controls[name]) { | |
controlName = name; | |
} | |
} | |
} | |
return controlName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment