HttpResponse没有提供程序-angular5 StaticInjectorError(AppModule)[AppComponent->;HttpResponse]

HttpResponse没有提供程序-angular5 StaticInjectorError(AppModule)[AppComponent->;HttpResponse],angular,http-headers,httpresponse,angular-httpclient,Angular,Http Headers,Httpresponse,Angular Httpclient,我想做一些我认为很基本的事情。 从一个简单的login.html页面开始,服务器会在响应中添加一个标题,以指定登录的用户-admin/company/customer response.setHeader("user", "admin"); 在Angular中,我所要做的就是访问这个响应标题,以确定我需要显示的组件是admin/company/customer response.setHeader("user", "admin"); 为此,我计划使用“HttpResponse”内容,并访问a

我想做一些我认为很基本的事情。 从一个简单的login.html页面开始,服务器会在响应中添加一个标题,以指定登录的用户-admin/company/customer

response.setHeader("user", "admin");
在Angular中,我所要做的就是访问这个响应标题,以确定我需要显示的组件是admin/company/customer

response.setHeader("user", "admin");
为此,我计划使用“HttpResponse”内容,并访问app.component构造函数中的头,如下所示:

constructor(private myResponse: HttpResponse<any>) {

var user = myResponse.headers.get("user");
我做错了什么? 截图:

HttpResponse不应作为服务导入。你能把代码贴在你要求登录的地方吗?登录页面在angular框架之外。只是一个普通的标准登录页面,带有名称、密码和“客户端类型”选择框。然后,它将该信息发送到一个专用servlet,该servlet确定该登录是否有效。如果是-则创建一个会话,在响应中添加一个带有“client type”的头,然后重定向到index.htmlIn。在这种情况下,在重新定向之后,您实际上无法访问响应。您应该从Angular应用程序发送登录请求。如果您只想将用户名传递给angular应用程序,只需在re direct上将其作为查询参数发送即可。