我有一个angular2 +页面从支付页面返回,其中包含表单数据标题中的状态信息,我如何在angular2中检索此信息
在asp.net中很容易通过Request.form [" Key"],在angular / Jquery应用程序中如何实现同样的东西
以下是获取的信息
答案 0 :(得分:0)
这可以使用HttpInterceptor完成(如果需要修改并记录请求)
@Injectable()
export class MyHttpInterceptor implements HttpInterceptor {
constructor() {}
intercept(req: HttpRequest < any > , next: HttpHandler): Observable < HttpEvent < any >> {
console.log("intercepted request ... ");
// Clone the request to add the new header.
const authReq = req.clone({
headers: req.headers.set("headerName", "headerValue")
});
console.log("Sending request with new header now ...");
//send the newly created request
return next.handle(authReq)
.catch((error, caught) => {
//intercept the respons error and displace it to the console
console.log("Error Occurred");
console.log(error);
//return the error to the method that called it
return Observable.throw(error);
}) as any;
}
}
答案 1 :(得分:0)