Below is my js code that is appending the route and its parameter in anchor tag.
var href = "{!! route('ShowUserMainForm', ['RoleID'=>" + row.RoleID + "]) !!}";
var UserColumn = "<td><a href=' " + href + "'><button>Users</button></a></td>";
It gives below url
http://localhost:1234/public/system-users/%20+%20row.RoleID%20+%20
I am expecting below.
http://localhost:1234/public/system-users/1
Am I missing anything?
No. of ways to do it:
Because {!! !!} block codes render before JavaScript code so you need to create route and then concat RoleID outside {!! !!} .
if row.RoleID is json :
var href = "public/system-users/" + row.RoleID
or
var href = "{!! route('ShowUserMainForm') !!}" + row.RoleID;
or
var href = "{!! route('ShowUserMainForm', ['RoleID'=>'']) !!}" + row.RoleID;
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