I canβt find out how to get all fields changed by user using angular2 forms. I did some research here and in the official docs of angular2, and I could not find such information.
Here 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 this using angular2 forms? I thought I would have some kind of changeValues ββproperty, but I can't find it.
EDIT
This is how my form is created: (Form permission 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] });
source share