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

269
Views
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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

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

over 4 years ago · Santiago Trujillo 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!