#Error Undefined

5 messages · Page 1 of 1 (latest)

rain goblet
#
async handleDocumentJustifycationDescription() {
    console.log('loop', this.regulatoryAffairs.regaffJustifications);

    this.regulatoryAffairs.regaffJustifications.forEach(function (nome, i) {
      console.log('[forEach]', nome.typJustification.name, i);
      (this.DocumentJustifycationDescription = nome.typJustification.name), i;
    });

    console.log('aqui2', this.regulatoryAffairs.regaffJustifications);
  }

why my variable DocumentJustifycationDescription are return undefined here?

nocturne pendant
#
async handleDocumentJustifycationDescription() {
  console.log('loop', this.regulatoryAffairs.regaffJustifications);

  this.regulatoryAffairs.regaffJustifications.forEach((nome, i) => {
    console.log('[forEach]', nome.typJustification.name, i);
    (this.DocumentJustifycationDescription = nome.typJustification.name), i;
  });

  console.log('aqui2', this.regulatoryAffairs.regaffJustifications);
}

because this isn't bound to your class if you use a function you need to use an Arrow function.

#

And in TypeScript you typically name classes and types in PascalCase, also known as CapitalCamelCase.
normal variables are done in camelCase; lowerCamelCase