| 12345678910111213141516171819202122232425262728293031323334 |
- @rendermode InteractiveServer
- @using BlazorWeb1.Server
- <h3>Todo (@todos.Count(todo => !todo.IsDone))</h3>
- <ul>
- @foreach (var todo in todos)
- {
- if(!todo.IsDone)
- {
- <li>
- <input type="checkbox" @bind="todo.IsDone" />
- <input @bind="todo.Title" />
- </li>
- }
- }
- </ul>
- <input @bind="newTodo" />
- <button @onclick="AddTodo">Add todo</button>
- @code {
- private List<TodoItem> todos = new();
- string newTodo = "";
- void AddTodo()
- {
- if (!string.IsNullOrWhiteSpace(newTodo))
- {
- todos.Add(new TodoItem { Title = newTodo });
- newTodo = string.Empty;
- }
- }
- }
|