05: Hydrate Todo Items

Hydrate todos to each child element of x-each element.

  1. Add todo variable name into x-each directive for hydrating each todo item.
  2. Add class binding directive to apply CSS class of completed item design to the todo item.
  3. Hydrate completed state of todo item to HTML template with x-model directive.
  4. Hydrate title of todo item to HTML template with mustache syntax.

<body>


    <section class="main">

      <ul class="todo-list"
        x-each="todo in todos"
      >
        <li class="todo"
          x-bind:class="{
            completed: todo.completed,
          }"
        >
          <div class="view">
            <input class="toggle" type="checkbox">
            <input
              class="toggle"
              type="checkbox"
              x-model="todo.completed"
            >
            <label>Todo Title (Active)</label>
            <label>{{ todo.title }}</label>
            <button class="destroy"></button>
          </div>
          <input class="edit">
        </li>
      </ul>
    </section>

  </section>
</body>
</html>