Can someone please provide guidance on how to assign the index value (i = index) to EmployeeIndex: any; after a button click event?
Your suggestions are greatly appreciated.
Here is my code:
HTML
<select class="form-control" [(ngModel)]="EmployeeName">
<option *ngFor="let employeeItem of getEmployeeeList(); let i = index" [value]="i">
{{employeeItem.EmployeeName}}
</option>
</select>
<button (click)="updateBook()" *ngIf="dep.No!=0" class="btn btn-primary">
Update
</button>
TS
EmployeeIndex : any;
updateBook() {
this.EmployeeId = this.employeeFiltered[this.EmployeeIndex].EmployeeId;
var val = {
No:this.No,
EmployerName:this.EmployerName,
EmployeeName:this.EmployeeName,
Project:this.Project,
Date:this.Date,
Spent:this.Spent,
VAT:this.VAT,
Total:this.Total,
Comment:this.Comment};
this.service.updateBook(val).subscribe(res=>{
alert(res.toString());
});
}