I am learning Blazor and as a lesson, I am passing 2 variables to the component.
It is not updating for me.
I do not know why.
Each successive call should create a new component and add the values, but it does not seem to change the second value. Trying to get the second value working first then I will add the first, which is hard coded in the component.
Thank you.
Component:
<div class="card" style="width: 4rem;">
@* <img class="card-img-top" src="@imageUrl" alt="Unit x" /> *@
<div class="card-body">
<h6 class="card-title">@Tactical</h6>
<p class="card-text">@Assignment</p>
</div>
</div>
@code {
[Parameter] public RenderFragment Tactical { get; set; }
[Parameter] public RenderFragment Assignment { get; set; }
}
Index.razor:
@page "/"
@using BlazorApp1.Component
<PageTitle>Index</PageTitle>
@{
string name = "";
string[] Assign = { "Sweep", "Rt35", "Rt48", "Rt100", "Rest E", "Cmd" };
Random rnd = new Random();
int a = 0;
string b = "";
@for(int x=0;x<3;x++) // Three rows
{
<div class="comp">
@for (int i = 0; i < 10; i++) // of 10 cards per row
{
a = rnd.Next(0,5);
b = Assign[a];
<p>@b</p>
<UnitComponent>
<Tactical>Sag-1</Tactical>
<Assignment>@b</Assignment>
</UnitComponent>
}
<br />
</div>
}
}
<div>End of Test</div>