I am getting the error:
StudentsAttendanceCreateComponent.html:9 ERROR TypeError: Cannot read property 'insertData' of undefined at students-attendance-create.component.ts:96 at Array.forEach ()
submitForm(form: NgForm) {
let cursoID: number;
Object.keys(form.value).forEach(function (key) {
if (key === 'cursoId') {
cursoID = form.value[key];
}
});
Object.keys(form.value).forEach(function (key) {
if (key !== 'cursoId') {
const json = {
EstudianteId: key,
asistencia: form.value[key],
cursoId: cursoID
};
this.insertData(json);
}
});
}
insertData(json: any) {
this.service.studentsAsistencia(json)
.subscribe(() => {
this.openSnackBar('Datos insertados correctamente.', 'OK');
});
// this.clearForm();
}
Thanks !!!!