To use "useExisting" in providers?

0

Seeing how dependency injection is done in angular 4. On entering to see more deeply the documentation of angular.io there is a "useExisting" option instead of the traditional "useClass":

// Forma tradicional
[ NewLogger,
// Not aliased! Creates two instances of 'NewLogger'
{ provide: OldLogger, useClass: NewLogger}]


// Esta es la que no entiendo
[ NewLogger,
// Alias OldLogger w/ reference to NewLogger
{ provide: OldLogger, useExisting: NewLogger}]

Does anyone know the difference between injecting with "useClass" to "useExisting"?

    
asked by Panchin 19.04.2018 в 20:10
source

0 answers