Issue
Q) If I've got an object with loads of properties, all bound to fields in a form, how do I catch when the object has changed?
I don't want to put (blur)
events on every field as the page is quite heavy already and this could lead to way too many listeners on the page.
E.g
Object:
var person = {
name: string,
email: string,
phone: string
};
Form:
<input [(ngModel)]="person.name" type="text" />
<input [(ngModel)]="person.email" type="text" />
<input [(ngModel)]="person.phone" type="text" />
Solution
you can use a form object and check if the form has changed.
I know that there have been some issues with latest release of Angular2 and Ionic2 with the new Forms module, but that would be my suggestion.
https://angular.io/docs/ts/latest/guide/forms.html
Answered By - Aaron Saunders
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.