Within my JavaScript code, there is a variable that holds a value:
var selectedItemId = null; // the value is assigned by another function
Next, there is a function defined like this:
function editLink() {
location.href = /*[[@{/supplycontracts/edit/}]]*/'';
}
Now, I aim to include the value of the variable in the href, resulting in a link like:
http://localhost:8080/myApp/supplycontracts/edit/?contractId=4
Here, the '4' represents the value of selectedItemId.
I attempted different approaches such as:
location.href = /*[[@{/supplycontracts/edit(${selectedItemId})}]]*/'';
However, these attempts were unsuccessful.
When I used:
location.href = /*[[@{/supplycontracts/edit(selectedItemId)}]]*/'';
The resulting link was:
http://localhost:8080/supply-app-0.0.1-SNAPSHOT/supplycontracts/edit?selectedItemId
How can I correctly pass the value of selectedItemId to the href in order to generate the desired link?