Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen #6

Open
web-dave opened this issue Mar 21, 2022 · 1 comment
Open

Listen #6

web-dave opened this issue Mar 21, 2022 · 1 comment

Comments

@web-dave
Copy link
Owner

web-dave commented Mar 21, 2022

Daten holen

  1. Hole den Service per DI in deine ShipsComponent
  2. Definiere ein neues Klassen Attribute für die Daten vom Service
  3. Rufe die ServiceMethode mit dem Richtigen Parameter auf
  4. Und speichere die Daten im Klassen Attr.
  5. Schau dir das Result an und überlege wie du an die Daten kommst.
  6. Zeige die Daten in einer Tabelle an
FilmsComponent
export class FilmsComponent implements OnInit {
  films: any;
  constructor(private service: ApiService) {}

  ngOnInit(): void {
    this.service
      .getList('films')
      .subscribe((data) => (this.films = data.results));
  }
}
Template
<table>
  <tr>
    <th>Titel</th>
    <th>Director</th>
    <th>Producer</th>
    <th>link</th>
  </tr>
  <tr *ngFor="let film of films">
    <td>{{ film.title }}</td>
    <td>{{ film.director }}</td>
    <td>{{ film.producer }}</td>
    <td><a [routerLink]="film.url">Mehr</a></td>
  </tr>
</table>
@web-dave
Copy link
Owner Author

Next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant