Michał Bednarz
Michał Bednarz

Reputation: 35

Angular 2 - making an URL

I'm looking for a way to build an url using variables in my component. I just want it to be dynamic.

Example: "https://www.youtube.com/results?search_query=skijumper.name"

So if my variable skijumper.name = "Ahonen"

= > this is what I want to achieve : https://www.youtube.com/results?search_query=Ahonen

Thanks in advance

Upvotes: 0

Views: 123

Answers (2)

Try this

   var url = "https://www.youtube.com/results?search_query="+skijumper.name;

Edit

ECMAscript6 :

let url = `https://www.youtube.com/results?search_query=${skijumper.name}`

Upvotes: 0

Swoox
Swoox

Reputation: 3740

let name = "Ahonen";
let urlYoutube = `https://www.youtube.com/results?search_query=${name}`;

Upvotes: 2

Related Questions