Currently, I'm encountering an issue in my Angular 7 code where it states "cannot set property 'nometape' of undefined." The problem lies within the initialization process of my interface "Process" which contains an array of objects called "Etape." Here are the interfaces:
export interface Process {
id : string,
etapes : Etape[],
}
export interface Etape {
nomEtape : string,
ordre : number,
etat : number,
remarque : string,
duree: string;
dateRDV : Date,
}
The object declaration looks like this:
proEdit : Process = {
id: "",
etapes : []
}
To initialize the process etapes array, I use the constructor with the following:
this.proEdit.etapes = [{
nomEtape : " ",
ordre : 0,
etat : 0,
remarque : "",
duree: "",
dateRDV : new Date(),
}] ;
The problem arises when I loop through the etapes array, resulting in the error message "cannot set property 'nometape' of undefined."
editProcess(){
for(let i = 0; i < this.productForm.value.etapes.length; i++) {
this.proEdit.etapes[i].nomEtape = this.productForm.value.etapes[i]["step"];
}