Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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 4中打开用户Id基本配置文件页面_Angular_Ruby On Rails 4 - Fatal编程技术网

我想在angular 4中打开用户Id基本配置文件页面

我想在angular 4中打开用户Id基本配置文件页面,angular,ruby-on-rails-4,Angular,Ruby On Rails 4,我想在angular 4中打开用户配置文件页面:- 我已从后端发送配置文件API:- http://localhost:3001/my_profile/2.json/?api_token=Uq3cv0E4UukGRolYO3x4p-Zog7rnVqefj1uMGaq7EGA 然后我对如何在服务中动态调用Userid(2)感到困惑 doProfile(token: any){ let data = new URLSearchParams(); data.append('api_t

我想在angular 4中打开用户配置文件页面:-

我已从后端发送配置文件API:-

http://localhost:3001/my_profile/2.json/?api_token=Uq3cv0E4UukGRolYO3x4p-Zog7rnVqefj1uMGaq7EGA
然后我对如何在服务中动态调用Userid(2)感到困惑

doProfile(token: any){
    let data = new URLSearchParams();
    data.append('api_token', token);
    return this.http.get(this.url+'my_profile/userId.json?'+'api_token='+token).map((response: Response) => response.json());
}

将参数传递给
doProfile
函数并使用它形成URL,然后由于您已经创建了
URLSearchParams
将其传递给
http
选项的
params
属性

doProfile(token: any, userId: number){
    let data = new URLSearchParams();
    data.append('api_token', token);
    return this.http.get(`${this.url}my_profile/${userId}.json`, {params: data })
           .map((response: Response) => response.json());
}

this.http.get(`${this.url}my_profile/${userId}.json?api_-token=${token}`)那样使用它……
这就是我想知道的。如何发送用户ID。this.friendservice.doProfile(this.globalService.user_token).subscribe((响应:any)=>{this.peopleKnow=response;this.loading=false;})@RahulWadhwa因此,通过调用
doProfile
函数,您应该传递
userId
以及
this.friendservice.doProfile(this.globalService.user\u token,userId)
正在工作,谢谢