Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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
Angular TypeError:无法读取属性';http';未定义的角2_Angular_Typescript_Angular Promise - Fatal编程技术网

Angular TypeError:无法读取属性';http';未定义的角2

Angular TypeError:无法读取属性';http';未定义的角2,angular,typescript,angular-promise,Angular,Typescript,Angular Promise,在我的Angular 2应用程序中成功实现gapi客户端之后,我现在遇到了一个问题,我的http对象未定义,我不知道为什么 代码如下: 构造函数(私有http:http){} 基本上,我正在做的是请求用户允许访问他的gmail帐户,当我得到响应时,我希望将收到的一些数据传递到我的后端服务器 如果我在“then”子句之外使用this.http,那么http方法可以正常工作,但是这会造成另一个问题,即无法识别“auth_code”值 我错过了什么 如果要在回调中引用此,请不要使用函数(){} 改用箭

在我的Angular 2应用程序中成功实现gapi客户端之后,我现在遇到了一个问题,我的http对象未定义,我不知道为什么

代码如下: 构造函数(私有http:http){}

基本上,我正在做的是请求用户允许访问他的gmail帐户,当我得到响应时,我希望将收到的一些数据传递到我的后端服务器

如果我在“then”子句之外使用this.http,那么http方法可以正常工作,但是这会造成另一个问题,即无法识别“auth_code”值


我错过了什么

如果要在回调中引用
,请不要使用
函数(){}

改用箭头功能:

then((resp) => {

你有一个函数:
function(resp)
,它正在改变你的
这个
你期望从类中得到的。使用箭头功能。
then((resp) => {