vendredi 17 septembre 2021

What is the benefits for injection a string in angular application

there is a good explanation in the ng-book about the Dependency injection, however the question about

   import { Inject } from "@angular/core";
export class AnalyticsDemoComponent {
constructor(@Inject("API_URL") apiUrl: string) {
// works! do something w/ apiUrl
}
}

what is the point of doing it as DI, is there a benefit compared to use a config variable ?

Aucun commentaire:

Enregistrer un commentaire