I have such kind of error after deployment to github-pages with angular-cli:
Error: "Can't resolve all parameters for e: (?)."
Local application works. What steps would you recommend to do to find the problem place?
Tried with angular-cli beta29 and beta30.
UPD: I've removed Router from the application for testing purposes. Not I have only one guess that it's something with DI.
UPD2(FOUND THE PLACE):
The problem is with overwriting RequestOptions
, so do:
export class RequestOptionsService extends RequestOptions {}
and for provider definition:
{ provide: RequestOptions, useClass: RequestOptionsService },
It's still a question for me.
RequestOptions
constructor - error.RequestOptions
constructor with empty parameter - no errorRequestOptions
constructor with parameters - errorThis is the way how I overwrite the constructor:
constructor(options?: RequestOptionsArgs) {
super(options);
}
What could be wrong here?
UPD3(Solved own case):
The problem indeed was with RequestOptions
, so you should not do:
export class RequestOptionsService extends RequestOptions {}
but only:
export class RequestOptionsService extends BaseRequestOptions {}
Make sure:
"emitDecoratorMetadata": true
in your tsconfig.js
@Injectable()
decoratorOfficial example is:
class MyOptions extends BaseRequestOptions {
search: string = 'coreTeam=true';
}
bootstrap(App, [HTTP_PROVIDERS, {provide: RequestOptions, useClass: MyOptions}]);
In fact, export class RequestOptionsService extends RequestOptions {}
should also work perfectly fine. May be it is angular-cli specific problem (i can do this on my setup).
If your service has non-optional parameter then @Injectable()
is a must. Also parameters must be provided (RequestOptionsArgs
in your case) or marked as @Optional()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With