Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从HttpInterceptor显示模式对话框_Javascript_Angular_Typescript_Angular Material_Httpinterceptor - Fatal编程技术网

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);
    }
  }
}