I am learning Angular 2. I am trying to implement autosave functionality using (change) event. Like this
<div>
<md-input class="ctrl" [(ngModel)]="first" (blur)="saveItemInfo()"></md-input>
</div>
<div>
<md2-autocomplete [items]="items" item-text="name" item-value="value" [(ngModel)]="second" [disabled]="disabled"
(change)="saveItemInfo()">
</md2-autocomplete>
</div>
<div>
<md-slide-toggle [(ngModel)]="third" color="primary" (change)="saveItemInfo()"></md-slide-toggle>
</div>
Here the problem is, change event is firing even when page loads. So that it is making so many api calls. Any other way to do this?
saveItemInfoto see if anything actually changed.(change)to(keyup)and check if it works for you.