Access service into static method in Angular 5

Discussão em 'Angular' iniciado por KevinTale, Fevereiro 19, 2025.

  1. KevinTale

    KevinTale Guest

    I'm trying to access the service's reference into my static method like so :

    export class myComponent {
    constructor(private backend: BackendService) { }

    public static myMethod() {
    myComponent.backend.getData()
    .subscribe(
    data => { console.log(data) },
    error => { console.error(error); }
    );
    }
    }


    I'm getting Property backend doesn't exist on type 'typeof myComponent'

    How can I access backend reference?

    Thanks.

    Continue reading...

Compartilhe esta Página