• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

113
Vistas
typescript private variables message

In my typescript class I have two private variables. One variable is goping to store a string that I am returning from an API. The other one is a message that I will be displaying to the user. Once the API is completed and will use the return and build the full message. In the response I am setting this.templatIds so it will build the message with the correct ids that. But in my popup message its missing the section from the string.

export class AgentsGridComponent implements AfterViewInit {
    private templatIds = "";
    private inuseItemMessage = `This Agent is being used by Templates ${this.templatIds} and can't be archived`




this.agentsService.inuseTemplateAgentList(data.item.Id)
                    .then((response) => {
                        console.log(response.Value);
                        this.templatIds = response.Value;
                        this.notificationManager.error(inuseItemMessage);
                    });
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The templatIds is not populated at the time that the inuseItemMessage is assigned to - they both get assigned at the same time, at the beginning of the constructor. Make the message into a function instead, so it can construct the template string from the now-populated templatIds on demand.

private getInUseMessage = () => `This Agent is being used by Templates ${this.templatIds} and can't be archived`
this.notificationManager.error(this.getInUseMessage());
almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda