5. Servicio (GET básico)

5.2. Plantilla (mostrar los posts)

Aquí trabajamos:

  • @for → Angular 17+

  • async pipe → sin subscribe

  • Flujo reactivo limpio

src/app/app.component.html

<h1>Listado de Posts</h1>
<p>GET básico · Angular moderno</p>

<ul>
  @for (post of posts$ | async; track post.id) {
    <li>
      <h3>{{ post.title }}</h3>
      <p>{{ post.body }}</p>
    </li>
  } @empty {
    <li>No hay posts</li>
  }
</ul>