<a class="btn btn-primary" type="button" href="/items/{restaurantDetails.RestUsername}">…
- User
weiter zur Speisekarte why doesnt this code work? Im using svelte. Which is the right syntax for dynamic links?
- Assistant
In Svelte, to create dynamic links with variables you must use the curly braces
{}inside the string, but since you're already inside an attribute value quoted by double quotes", you can't use curly braces directly because they are reserved for Svelte expressions in the HTML part of a component.You can use the
{@html ...}directive to inject raw HTML, but for dynamic attributes such ashref, it is not necessary and not recommended due to the potential risks of injecting unescaped HTML.Instead, you should use string interpolation within an expression. Here is the correct syntax for creating a dynamic link in Svelte:
svelte - User
It says restaurant username is undefined. The injection isnt working
- Assistant
If you're getting an error that says
restaurantDetails.RestUsernameis undefined, this suggests that eitherrestaurantDetailshas not been properly defined or passed to the component, or it does not have a property called .