I'm developing a web application using Angular 6.
I created an interceptor service (using the interface HttpInterceptor
) which intercepts some types of HTTP calls.
The class works perfectly (I can intercept all the HTTP calls that I want).
In this application there are several graphic components. What is the way to show a graphic component (for example a spinner or a modal window) using code written in the interceptor?
An example:
@Injectable()
export class MyHttpInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler ) {
let updateReq;
updateReq = req.clone({
setParams: {
responseType: 'no-type'
}
}
);
console.log(updateReq);
return next.handle(updateReq).pipe(tap(
event => console.log(event),
err => console.log(err)
));
}
}
For example I would like to test if req
has some properties,
then I make a graphic component appear. How do I do this throughout my application?