Skip to content

Instantly share code, notes, and snippets.

@chasebaker21
Last active November 19, 2020 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chasebaker21/ac8d6729095ebdfc2f7855d1a88b9d00 to your computer and use it in GitHub Desktop.
Save chasebaker21/ac8d6729095ebdfc2f7855d1a88b9d00 to your computer and use it in GitHub Desktop.
// updates the timesheet hours everytime the inputs are changed
onChanges() {
this.projectForm.get('projectTime').valueChanges.subscribe(val => {
let x = val.length;
for (let i = 0; x > i;) {
let total = (Number(val[i].hoursHashMap.Sunday.hours)
+ Number(val[i].hoursHashMap.Monday.hours)
+ Number(val[i].hoursHashMap.Tuesday.hours)
+ Number(val[i].hoursHashMap.Wednesday.hours)
+ Number(val[i].hoursHashMap.Thursday.hours)
+ Number(val[i].hoursHashMap.Friday.hours)
+ Number(val[i].hoursHashMap.Saturday.hours));
this.projectWeekTotals.splice(i, 1, total);
i++;
this.getTotalHours();
this.project.emit(this.projectForm);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment