Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@page "/lista-de-tarefas"
<h1>Lista de tarefas</h1>
<ul>
@foreach(var tarefa in tarefas)
{
<li>@tarefa.Titulo</li>
}
</ul>
<input placeholder="Alguma coisa para fazer..." @bind(novaTarefa) />
<button @onclick(AdicionarTarefa)>Adicionar tarefa</button>
@functions {
IList<TarefaModel> tarefas = new List<TarefaModel>();
string novaTarefa;
void AdicionarTarefa()
{
if(!string.IsNullOrWhiteSpace(novaTarefa))
{
tarefas.Add(new TarefaModel { Titulo = novaTarefa });
novaTarefa = string.Empty;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment