I'm trying to pass two variables in a href (with the route()
function, I'm using Laravel) in the innerhtml, but an error occurs because the way I'm passing the parameters is probably wrong.
The variable I'm passing is an array of objects called title and within them there are these variables id_cliente and id_tipo_titulo.
<a
href="{{ route('mostrarTitulosUser', [
'id_cliente' => ${titulo.id_cliente},
'id_tipo_titulo' => ${titulo.id_tipo_titulo}
])}}"
target="_blank"
>
CodePudding user response:
It looks like you are using the wrong syntax for passing the variables to the route function. In order to pass the variables, you should use the $
symbol followed by the variable name. In your code, you are using ${titulo.id_cliente}
and ${titulo.id_tipo_titulo}
which is not correct.
You should use $titulo->id_cliente
and $titulo->id_tipo_titulo
instead.
Here is the correct way to pass the variables:
<a
href="{{ route('mostrarTitulosUser', [
'id_cliente' => $titulo->id_cliente,
'id_tipo_titulo' => $titulo->id_tipo_titulo
])}}"
target="_blank"
>
CodePudding user response:
<a
href="{{ route('mostrarTitulosUser', ['id_cliente' => $titulo->id_cliente, 'id_tipo_titulo' => $titulo->id_tipo_titulo]) }}"
target="_blank"
>
</a>
or just
<a
href="{{ route('mostrarTitulosUser', [$titulo->id_cliente, $titulo->id_tipo_titulo]) }}"
target="_blank"
>
</a>