@using Microsoft.AspNetCore.Authorization;
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
@using MyRecipes2.Shared;
@using System;
@using System.IO;
@using System.Text;
<div>
@for (int i = 0; i < MethodSteps.Count; i++)
{
var index = i;
<div class="form-group">
<label for="methodstep">@index)</label>
<textarea @bind="MethodSteps[index]" class="form-control" id="methodstep" rows="2"></textarea>
</div>
<button class="btn btn-danger mb-2" @onclick="() => ClickRemoveStep(index)">Remove</button>
}
<div class="form-group">
<textarea @bind="CurrentStep" class="form-control" rows="2"></textarea>
</div>
<button class="btn btn-primary mb-2" @onclick="ClickAddStep">Add Step</button>
</div>
@code {
public List<string> MethodSteps { get; set; }
public void SetMethodSteps(List<string> methodSteps)
{
MethodSteps = methodSteps;
StateHasChanged();
}
private string CurrentStep { get; set; }
protected override void OnInitialized()
{
MethodSteps = new List<string>();
CurrentStep = "";
}
protected void ClickAddStep()
{
MethodSteps.Add(CurrentStep);
CurrentStep = "";
}
protected void ClickRemoveStep(int i)
{
Console.WriteLine(i);
MethodSteps.RemoveAt(i);
}
}