Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

public getQuestionsById(qid:number): Observable<Questions>{
 return this.httpClient.get<Questions> 
  ('http://localhost:9090/angular/questions/${qid}');
  
}

Here, I want to concatenate the "qid" variable value in this URL. What should be the right format for that?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

You just have to use Template literals for that. Check the basics you are just using wrong operator. please not use single quote here, use backquot for that.

public getQuestionsById(qid:number): Observable<Questions>{
    return this.httpClient.get<Questions>(`http://localhost:9090/angular/questions/${qid}`);
     
   }

Best of luck :)

link : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...