1

Using this data model code in Angular:

export class Car {
  brand: string;
  year: number;
  nameOfModel() => {
    // I need return here the name of class as a string: 'Car'
  }
}

Can I somehow get back the name of the class as a string?

netdjw
  • 5,419
  • 21
  • 88
  • 162
  • @KristófTóth : how is this working inside of the class if the model has a 'name' attribute? – netdjw Feb 13 '19 at 12:50

1 Answers1

1

This works for me:

export class Car {
    brand: string;
    year: number;
    nameOfModel: string = () => {
        return Car.name
    }
}
Kristóf Tóth
  • 791
  • 4
  • 19