Javascript 从HttpInterceptor显示模式对话框
可以通过“角度材质”对话框执行此操作:Javascript 从HttpInterceptor显示模式对话框,javascript,angular,typescript,angular-material,httpinterceptor,Javascript,Angular,Typescript,Angular Material,Httpinterceptor,可以通过“角度材质”对话框执行此操作: return next.handle(req); else route to login } } > I have tried to show a angular material dialog but it does not block > the request and continue execute to next line. > > How to show a modal di
return next.handle(req);
else
route to login
}
}
> I have tried to show a angular material dialog but it does not block
> the request and continue execute to next line.
>
> How to show a modal dialog from intercepter on finding the request is
> errored out, show user some options and resume execution after dialog
> is closed.
>
> Is it possible to stop/hold a request with such dialog?
@Injectable()
导出类MyInterceptor实现HttpInterceptor{
构造函数(专用对话框:MatDialog,专用路由器:路由器){}
截取(req:HttpRequest,next:HttpHandler):可观察{
if(ShowModalDialog()){
返回此.dialog.open(DialogModalComponent).afterClosed()管道(
concatMap(()=>next.handle(请求))
);
}否则{
返回next.handle(req);
}
}
}
您使用的是哪种模式对话框?你用的是棱角材料吗?@PoulKruijt,是的。我已经更新了问题
return next.handle(req);
else
route to login
}
}
> I have tried to show a angular material dialog but it does not block
> the request and continue execute to next line.
>
> How to show a modal dialog from intercepter on finding the request is
> errored out, show user some options and resume execution after dialog
> is closed.
>
> Is it possible to stop/hold a request with such dialog?
@Injectable()
export class MyInterceptor implements HttpInterceptor {
constructor(private dialog: MatDialog, private router: Router) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if(ShowModalDialog()) {
return this.dialog.open(DialogModalComponent).afterClosed().pipe(
concatMap(() => next.handle(req))
);
} else {
return next.handle(req);
}
}
}