Questions tagged «angular-dependency-injection»

3
APP_INITIALIZER引发“无法实例化循环依赖性!“ ApplicationRef_”与重定向的自定义Http提供程序一起使用时
我正在使用自定义Http提供程序来处理API身份验证错误。在我的CustomHttp中,当API发出401状态错误时,我需要将用户重定向到登录页面。很好! 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 ... { provide: Http, useFactory: loadCustomHttp, deps: [XHRBackend, RequestOptions, Router, DataHelperService] } }); 自定义http.ts import { Injectable } from …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.