Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.
This repository was archived by the owner on Feb 16, 2021. It is now read-only.

Injecting into ServerURLInterceptor #9

@IonPopescu

Description

@IonPopescu

I am converting an Angular 1 application, and I have some existing authentication-related functionality that I'd like to reuse:

export function Auth ($rootScope, $q: ng.IQService, $injector, $window: ng.IWindowService) {
    // auth functionality is here...
}

Auth.$inject = [
    "$rootScope", "$q", "$injector", "$window"
];

In the provided example, would it be possible to inject the Auth function above into ServerUrlInterceptor?

providers: [
        {
            provide: InterceptorService,
            useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions) => {
                let service = new InterceptorService(xhrBackend, requestOptions);
                service.addInterceptor(new ServerURLInterceptor(/* TODO: inject Auth here (??) */)); 
                return service;
            },
            deps: [XHRBackend, RequestOptions]
        }
    ]

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions