ngUpgraders / ng-forward

The default solution for those that want to write Angular 2.x style code in Angular 1.x
410 stars 36 forks source link

Provider not injecting given class instance in useClass, it instead injects the original class #129

Closed panjiesw closed 8 years ago

panjiesw commented 8 years ago

Hi, I'm trying to build a configurable provider with ng-forward. I'm using angular2/http as reference, where the Http instance is injected based on RequestOptions. As you know, injected Http instance is configured by providing RequestOptions implementation using provide function, which is then injected in useFactory of Http.

In this plunkr i created MyClass to be injected in AppCtrl which should be pointed to MyClassFoo extends MyClass instance. But instead of getting myClass.something to be foo, it still points to default, in which case, the original MyClass instance.

Meanwhile in this plunkr i implemented above scenario in angular 2 and it works as expected.

If i use string token or OpaqueToken, it also works as expected.

Is there something i missed?

Edit: In provider.spec.ts, I noticed you guys missing useClass test where the token is the class itself and the value of useClass points to different class. Maybe my scenario above has not been covered?