With the new angular 2 DI we can do this:
import HeroService from './HeroService';
bootstrap(AppComponent, [provide(HeroService,{useClass:HeroService})]);
There is a way to code to an interface so we can do this?
// typescript does not compile interfaces to plain js, we can use this in the provide function?
interface SomeInterface { name: string }
class HeroService implements SomeInterface {}
bootstrap(AppComponent, [provide(SomeInterface,{ useClass: HeroService })]);
// component
class myComponent {
constructor(hero: SomeInterface) {}
}