1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Cannot access getter of base class

Discussão em 'Angular' iniciado por Pawan Nogariya, Setembro 24, 2024.

  1. I have a base class like this

    export class ShortNameFullNameBaseDto extends DtoBase<number> {
    public shortName: string = '';
    public fullName: string = '';

    public get uniqueName(): string {
    return `${this.shortName} - ${this.fullName}`;
    }
    }


    And an inherited class like this

    export class FundDto extends ShortNameFullNameBaseDto {
    public sebiRegistrationNumber: string = '';
    public investmentManagerName: string = '';
    public sponsorName: string = '';
    public merchantBankerName: string = '';
    public legalAdvisorName: string = '';
    public fundHouseId: number = null;
    public fundHouse: FundHouseDto = null;
    }


    I load FundDto from web api, after that I am expecting that when I will call FundDto.uniqueName property I should get it but I am always getting this property undefined.

    This is how I am loading array of FundDto objects

    this.commonService.getAllFunds(e.value).then(response => {
    if (response.isSuccess) {
    this.funds = response.data;
    }
    });


    What am I doing wrongly?

    It is the loading of object from web api response creating the problem?

    Update

    I just tried this code and it works perfectly. So looks like it is because I am copying the data to FundDto object which I receive from web api response and the response does not have uniqueName property.

    const fund = new FundDto();
    fund.shortName = 'short name';
    fund.fullName = 'full name';

    console.log(fund.uniqueName); // here it works


    How to make it work in this case then?

    Continue reading...

Compartilhe esta Página