Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Why child class doesnt refresh value of another child class Angular

I've encountered a problem with typescript. schematically, I have :

  • parent abstract class A.

  • child class B.

  • child class C.

      export abstract class BasePage {
    
          public value = 1;
    
      }
    
      @Component({...}) // selector, template ...
      export class A extends BasePage{
          constructor(){}
    
          editValue(){
            this.value = 3;
          }
      }
    
      @Component({...}) // selector, template ...
      export class B extends BasePage{
          constructor(){}
      }
    
      <!-- B template -->
      <p> Parent abstract value : {{ value }}<!-- still remain 1 --> </p>
    

In parent class A, I have the property "value" which is used in both child classes. But it doesn't refresh in the B class when I launch editValue() in A class simultaneously.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

May be the answer of your question lies in the explanation how javascript understands subclass and parent class, when you call

editValue(){
        this.value = 3;
      }

this function the "this" belongs to the class A not to the BaseClass,

Also in TS when you extend a class you need to call super() in the constructor which will initialise value as 1, next time when you call the editValue you are essentially changing the class property not the parent class property

look how TS is converted in JS from this example from TS playground,

enter image description here

here you are dealing with different objects

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda