i have a problem with my Blazor app, there are 2 input and 1 button
<div class="form-group">
<label class="form-label">Фильм</label>
<input type="text" class="form-control" @bind="@filmname" placeholder="Введите название" required>
</div>
<div class="form-group">
<label>Год</label>
<input type="text" class="form-control" @bind="@year" placeholder="Введите год выхода фильма">
<small class="form-text text-muted">Это необязательное поле</small>
</div>
<div class="col-4">
<button class="btn btn-primary" id="sendbutton" type="submit" @onclick="GetData" disabled=@isLoading>Получить результат</button>
</div>
In GetData method i call another method with arg like "filmname + year"
@code {
private List<string>? answers = null;
private bool isLoading = false;
public string filmname = "";
public string year = "";
private int check = 1;
private async Task GetData()
{
check = 0;
isLoading = true;
string Text = "конец света";
@* if (year != "")
Text = filmname + " " + year;
else
Text = filmname;*@
answers = new List<string>();
check = 0;
answers = await Data.Exec.GetScoreAsync(Text);
isLoading = false;
check = 1;
StateHasChanged();
}
}
But it doesnt show up on the page, btw if its important when i define string Text in GetData and dont touch input forms all works good. Whats the problem here?
Try to show elements of "answers" like this:
@if (check == 0)
{
<p>Loading [@answers?.Count] ...</p>
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
}
@if (answers == null || answers.Count == 0)
{
<p>no data</p>
}
else
{
<p>@answers[0]</p>
<p>@answers[1]</p>
<p>@answers[2]</p>
<p>@answers[3]</p>
}
Getdata
public static async Task<List<string>> GetScoreAsync(string FilmName)
{
List<string> alldata = new List<string>();
List<string> comments = await Program.ParserExec(FilmName, false);
List<string> scores = new List<string>();
List<string> comments_new = Norm(comments);
List<string> positive = new List<string>();
List<string> negative = new List<string>();
foreach (string comment in comments_new)
{
ModelInput input = new ModelInput()
{
Review = comment
};
ModelOutput result = ConsumeModel.Predict(input);
scores.Add(result.Prediction);
if (result.Prediction == "0")
negative.Add(result.Prediction);
else
positive.Add(result.Prediction);
}
double last_score = 0;
foreach (string score in scores)
last_score += Convert.ToInt32(score);
last_score /= scores.Count;
last_score *= 10;
alldata = new List<string>();
alldata.Add(Math.Round(last_score, 1).ToString());
alldata.Add(scores.Count.ToString());
alldata.Add(positive.Count.ToString());
alldata.Add(negative.Count.ToString());
Dictionary<string, double> scoresDictionary = ExecIvi.Exec(FilmName);
return alldata;
answers.