hbc
hbc

Reputation: 43

emberJs giving different routes to links

I got a page that includes 15 pictures and I must redirect user to the details page if one of them is clicked. so, I have 15 different routes like 1,2,3,...15. But as I know, I cant give dynamic variable to #link-to helper. So how am I gonna make every picture go to its own route? this is how my index page .hbs looks like :

{{#each model as |rentalUnit|}}
  {{rental-listing rental=rentalUnit}}
{{/each}}
{{outlet}}

This is how I print every picture. And this is how am I trying to go to routes :

  {{#link-to "???"}}<img src={{rental.image}} width="200">{{/link-to}}

so, there is ??? because I dont know what to do. Thanks!

Upvotes: 0

Views: 55

Answers (1)

Lux
Lux

Reputation: 18240

Well, first why not use a dynamic segment in your route? Like this:

this.route('image', {path: '/images/:id'});

But what you want can be done by just passing a variable, not a string to the link to helper as first argument:

{{#link-to target}}

Where {{target}} would print your route name. So target is a variable here, not a string.

Checkout this twiddle.

Upvotes: 1

Related Questions