How to call a Blazor component with Typeparameters from menu with href

28 Views Asked by At

I have a Blazor component, that implements thre type paramters like this

@typeparam T where T : class
@typeparam V where V : class
@typeparam P where P : class

I use this component like this

<MyComponent T="Location" V="LocationView" P="LocationParent" />

If I want to call this component from a menu, I wonder how can I pass the typeparam (and perhaps other parameters) to this component?

<li><a class="dropdown-item" href="/LocationData">Locations</a></li>

I added the @page "/LocationData" to the component, but how to pass typeparam and paramters?

At this time I create an empty razor component, like this

LocationIndex.razor
@page "/LocationIndex"
<MyComponent T="Location" V="LocationView" P="LocationParent" WhereClause="deleted eq false" />

And from the menu calling LocationIndex instead of LocationData directly

<li><a class="dropdown-item" href="/LocationIndex">Locations</a></li>

So this works fine, but is it the right way? And how can I call this directly from the menu with an href? Is this possible, and does it make sense? Or is the additional "index" component the best way?

0

There are 0 best solutions below