Why needed private accessor in constructor's parameter?

Discussão em 'Angular' iniciado por Michael, Fevereiro 26, 2025.

  1. Michael

    Michael Guest

    I have this code:

    export class HeroService {

    constructor(private logger: Logger) { }

    getHeroes() {
    this.logger.log('Getting heroes ...');
    return HEROES;
    }
    }


    Logger in constructor of typescript class that can be injected, but what the point of private accessor?

    Why needed private accessor in constructor?

    Continue reading...

Compartilhe esta Página