I'm trying to accomplish something like the code below but I can't seem to figure out how to do it.
@page "/"
<div>@test</div>
@code {
[Parameter]
public string Animal { get; set; }
private BaseComponent test { get; set; }
protected override async Task OnInitializedAsync()
{
switch (Animal)
{
case "Cat": test = <Cat>Fluffy</Cat>; break;
case "Dog": test = <Dog>Woff</Dog>; break;
default: test = <p>None</p>
}
}
I also want to be able to put components in a dictionary like new Dictionary<string, BaseComponent> { {"cat", <Cat>test</Cat> }}
any ideas?