0

I am trying to create a dynamic url in my Aangualr2 App. I passed the id to the a service and I appended it as below:

ServiceDesk/DashBoard/${id}/Gadget

When I run my app, it is throwing an error because the url is generated as below instead of id getting replaced with the below string instead of value 1.

ServiceDesk/DashBoard/$%7Bid%7D/Gadget
5
  • could you add code where you are modifying this URL? Commented Mar 8, 2017 at 21:36
  • Please see the code below. This is a method in my app.service.ts. Basically I need to append the variable id, while making the below http request.When I see the network tab, the ${id} is replaced with $%7Bid%7D, instead of 1. getGadgetsData(id: string) { return this._http.get('devsrv/API/api/Desk/DashBoard/Gadget/${id}/Data') .map((res: Response) => res.json()); } Commented Mar 8, 2017 at 21:47
  • have you tried backquote (`) instead of regular quote ('), `devsrv/API/api/Desk/DashBoard/Gadget/${id}/D‌​ata`? Commented Mar 8, 2017 at 21:59
  • Works now with the change. Thanks. Appreciate your help. Commented Mar 8, 2017 at 22:06
  • great, I will post this answer then and you can accept it :). Commented Mar 8, 2017 at 22:07

1 Answer 1

2

You need to use backtick or back quote (`) instead of regular quote (').

For example:

`devsrv/API/api/Desk/DashBoard/Gadget/${id}/D‌​ata`
Sign up to request clarification or add additional context in comments.

1 Comment

any documentation about this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.