I want to create a component which needs to generate dynamics links. I tried passing the link data as an array, but this does not work.
var user1 = get("store").find("user", 1);
var data = {link: ["users.show", user1], title: "User1"};
{{#link-to data.link}}{{data.title}}{{/link-to}}
This should be equal to
{{#link-to "users.show" 1}}{{data.title}}{{/link-to}}
How to generate fully dynamic links from a variable?
You can specify an array as params
argument into a link-to
helper. Similar to nickiaconis' answer answer, but with just the default {{link-to}}
helper:
{{#link-to params=data.link}}{{data.title}}{{/link-to}}
...will render something like:
<a href="/users/show/1">User1</a>
(tested with Ember 2.3.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With