I have created timesheet module , here 1st column (3, 3, 3, 3, 3) when ever I entered all it's ok but again when ever I entered 2nd column (5, , , , 5) the three row is not filled me but when ever I submit this it is getting all the rows like this(5,3,3,3,5). i this 1st column data is getting the empty things.
below is payload code:
dayListDetail: [{workdate: "2021-11-29", hoursspent: 5}, {workdate: "2021-11-30", hoursspent: 3},…]
0: {workdate: "2021-11-29", hoursspent: 5}
1: {workdate: "2021-11-30", hoursspent: 3}
2: {workdate: "2021-12-01", hoursspent: 3}
3: {workdate: "2021-12-02", hoursspent: 3}
4: {workdate: "2021-12-03", hoursspent: 5}
here is Angular code:component.ts file
for (var i=0; i<counter; i++){
dayArr = [];
if (this.tform.value.timesheet[i].mon != null && this.tform.value.timesheet[i].mon != ''){
monObj = {
workdate: arr[0].date,
hoursspent: Number(this.tform.value.timesheet[i].mon)
}
console.log('Hi');
console.log(monObj);
}
if (this.tform.value.timesheet[i].tue != null && this.tform.value.timesheet[i].tue != ''){
tueObj = {
workdate: arr[1].date,
hoursspent: Number(this.tform.value.timesheet[i].tue)
}
console.log(tueObj);
}
if (this.tform.value.timesheet[i].wed != null && this.tform.value.timesheet[i].wed != ''){
wedObj = {
workdate: arr[2].date,
hoursspent: Number(this.tform.value.timesheet[i].wed)
}
console.log(wedObj);
}
if (this.tform.value.timesheet[i].thur != null && this.tform.value.timesheet[i].thur != ''){
thursObj = {
workdate: arr[3].date,
hoursspent: Number(this.tform.value.timesheet[i].thur)
}
console.log(thursObj);
}
if (this.tform.value.timesheet[i].fri != null && this.tform.value.timesheet[i].fri != ''){
friObj = {
workdate: arr[4].date,
hoursspent: Number(this.tform.value.timesheet[i].fri)
}
console.log(friObj);
}
dayArr.push(monObj, tueObj, wedObj, thursObj, friObj);
tmpPayloadObj = {
timesheetId: this.tform.value.timesheet[i].timesheetId!=undefined?this.tform.value.timesheet[i].timesheetId:0,
projectid: this.tform.value.timesheet[i].project,
taskid: this.tform.value.timesheet[i].task,
dayListDetail: dayArr,
totalHours: 0
}
finalArr.push(tmpPayloadObj)
}