1

I've been finding ways to set parameter for this kind of url but I couldn't

http://localhost:9111/v1/companies/{company}/users

where {Company} is the parameter

Anyone have an idea of how to set parameters for this url?

2 Answers 2

2

You can easily use template literals!

let company = 'google';

return this.http.get(`http://localhost:9111/v1/companies/${company}/users`);
Sign up to request clarification or add additional context in comments.

1 Comment

This needs to use backticks, not single quotes.
1

Slight update

Just jumping to this section will probably be faster: https://angular.io/docs/ts/latest/guide/router.html#!#link-parameters-array

original

Reading around this section of the angular docs should explain in detail what you're trying to do: https://angular.io/docs/ts/latest/guide/router.html#!#route-def-with-parameter

In your routing module you define the route in the form ~ { path: 'v1/companies/:companyId/users', component: TheComponent }

Comments

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.