I am using Anular9
and using mat-raised-button
as below:
<button mat-raised-button (click)="saveClick()" color="primary"><mat-icon>check</mat-icon> Ok</button>
The saveClick()
is defined as below
saveClick() {
for (let i = 0; i < this.hostid.length; i++) {
const saudit: SInterface = {
data: this.data,
eid: this.eid[i],
serverId: this.hostid[i]
};
this.subs.sink = this.sservice.addRecord(saudit)
.subscribe(s => {
this.dialog.close();
});
}
}
Here data
is common for all the records.
The above code is only saving the first record with i=0
.
How to change saveClick()
so that it saves all records until i < this.hostid.length
?