angular-dependency-injection

APP_INITIALIZER raises “Cannot instantiate cyclic dependency! ApplicationRef_” when used with a custom Http provider that is redirecting

寵の児 提交于 2019-11-27 10:25:37
问题 I am using a custom Http provider to handle API authentication error. In my CustomHttp, I need to redirect the user to the login page when a 401 status error is emitted by the API. That works fine! app.module.ts export function loadCustomHttp(backend: XHRBackend, defaultOptions: AppRequestOptions, router: Router, dataHelper: DataHelperService) { return new CustomHttp(backend, defaultOptions, router, dataHelper); } @NgModule({ // some declarations, imports, ... providers: [ // some services ..