blazor project for cs
This commit is contained in:
32
TodoList/Pages/Todo.razor
Normal file
32
TodoList/Pages/Todo.razor
Normal file
@ -0,0 +1,32 @@
|
||||
@page "/todo"
|
||||
|
||||
<PageTitle>Todo</PageTitle>
|
||||
|
||||
<h1>Todo (@todos.Count(todo => !todo.IsDone))</h1>
|
||||
|
||||
<ul>
|
||||
@foreach (var todo in todos)
|
||||
{
|
||||
<li>
|
||||
<input type="checkbox" @bind="todo.IsDone" />
|
||||
<input @bind="todo.Title" />
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
<input placeholder="Something todo" @bind="newTodo" />
|
||||
<button @onclick="AddTodo">Add todo</button>
|
||||
|
||||
@code {
|
||||
private List<TodoItem> todos = new();
|
||||
private string? newTodo;
|
||||
|
||||
private void AddTodo()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(newTodo))
|
||||
{
|
||||
todos.Add(new TodoItem { Title = newTodo });
|
||||
newTodo = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user