Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
No se pueden leer las propiedades de undefined (leyendo 'substr')

Hola, estoy tratando de obtener una subcadena de una cadena basada en algunos cálculos, pero aparece este error en la consola del navegador:

 TypeError: Cannot read properties of undefined (reading 'substring') at MessageVariantCardInputComponent.onInput at MessageVariantCardInputComponent_input_HostBindingHandler

cuando se usa el ejemplo de código a continuación para obtener el valor de subcadena de "valor"

Código:

 @HostListener('input') onInput() { this.triggerFound = false; this.triggerName = ''; const native = this.element.nativeElement; console.log("=== native dropdown", native) const value = native.value; const currentPos = native.selectionStart - 1; for (const key of Object.keys(this.triggers)) { const trigger = this.triggers[key]; const triggerLen = trigger.length; const extractedString = value.substr(currentPos - triggerLen + 1, triggerLen); const found = extractedString === trigger; const isFirstTrigger = key === 'firstElement'; if ((isFirstTrigger && found && currentPos === 0) || // allow first element trigger only when current pos is 0 (!isFirstTrigger && found) ) { this.triggerFound = true; this.triggerName = trigger; break; } } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Qué obtienes en tu console.log?

 console.log("=== native dropdown", native) ?
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!