Issue
Hi I need get all value (disabled field too), so I use getRawValue() but I don`t want invalid field value. What can I do ?
Solution
I would do something like that:
private function _getValuesNotInvalid(): any {
const rawValues = this.form.getRawValue();
Object.keys(this.form.controls).forEach(item => {
if(!this.form.get(item).valid) {
delete(rawValues[item])
}
});
return rawValues;
}
PS: _getValuesNotInvalid(): >>> any <<<
is not recomended, since any is not a great way to achieve things. Said that you can create a custom interface to solve that.
Answered By - Jacopo Sciampi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.