Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Passing parameter to Link #52

Closed
dj0nny opened this issue Nov 1, 2019 · 1 comment
Closed

Passing parameter to Link #52

dj0nny opened this issue Nov 1, 2019 · 1 comment

Comments

@dj0nny
Copy link

dj0nny commented Nov 1, 2019

Hello guys,

I have a route:

<Route path="/comment/:postId" component={Comment} />

inside my PostList.svelte component. I have a Link defined in this way:

<Link href="/comment/???"> { item.comments_count } comments </Link>

My question is, how do I pass the id of the post inside Link's href prop? I have tried many solutions but none of these seems work 😭

Thanks to all in advance 😀

@pateketrueke
Copy link
Contributor

You need to access the router prop:

<script>
  import { Link } from 'svero';
  export let router;
</script>

<Link href="/comment/{router.params.postId}">...</Link>

@kazzkiq kazzkiq closed this as completed Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants