I can't find out how to retrieve all fields modified by the user using angular2 forms. I did some research here and on angular2 official forms docs and I couldn't find such information.
This is how I do it using jQuery:
this.isFormDirty = function (form) {
var changeNames = [];
$(form).find(":input:not(:button):not([type=hidden])").each(function () {
if ((this.type == "text" || this.type == "textarea" || this.type == "number" || this.type == "hidden" || this.type == "file") && this.defaultValue != this.value) {
changeNames.push(this.name);
} else {
if ((this.type == "radio" || this.type == "checkbox") && this.defaultChecked != this.checked) {
changeNames.push(this.name);
} else {
if ((this.type == "select-one" || this.type == "select-multiple")) {
for (var x = 0; x < this.length; x++) {
if (this.options[x].selected != this.options[x].defaultSelected) {
changeNames.push(this.name);
}
}
}
}
}
});
return changeNames;
};
Is there a way to do that using angular2 forms? I thought I'd have some sort of changedValues property, but I can't find it.
EDIT
This is how my form is created: (permissionForm is of type FormGroup)
this.permissionForm = this.fb.group({
FullUrl: ['', Validators.required],
Area: ['', Validators.required],
Controller: ['', Validators.required],
Action: ['', Validators.required],
Name: ['', Validators.required],
Description: ['', Validators.required],
ParentPermissionId: ['', Validators.required],
ShowInMenu: ['', Validators.required],
Order: ['', Validators.required],
Icon: ['', Validators.required]
});