In the realm of my Angular2 application, I have two essential services called WebStorageService
and MobileStorageService
, both of which impeccably implement an interface known as IStorageService
. Interestingly, in my magnificent main.component
, I elegantly bootstrap the app with the distinguished WebStorageService
. However, in one of the components, a fascinating endeavor unfolds as I strive to acquire the provider within the constructor utilizing the following approach:
// main.component
bootstrap(AppComponent,[WebStorageService]) // WebStorageService flawlessly implements the esteemed IStorageService interface
//AppComponent
import {IStorageService} from "./IStorageService"
@Component
export class AppComponent {
constructor(private _storage: IStorageService) { } <-- An error interrupts this harmonious establishment - Can't resolve all parameters for AppComponent
}
Ergo, dear comrades, I am compelled to inquire - is there by any chance a method that would allow me to provide the service employing the Interface as the illustrious type?