Differenzansicht 01-components
im Vergleich zu 00-base

← Zurück zur Übersicht | Demo | Quelltext auf GitHub
src/app/app.component.html CHANGED
@@ -0,0 +1,3 @@
 
 
 
1
+ <main>
2
+ <bm-book-list></bm-book-list>
3
+ </main>
src/app/app.module.ts CHANGED
@@ -3,10 +3,12 @@ import { BrowserModule } from '@angular/platform-browser';
3
 
4
  import { AppRoutingModule } from './app-routing.module';
5
  import { AppComponent } from './app.component';
 
6
 
7
  @NgModule({
8
  declarations: [
9
- AppComponent
 
10
  ],
11
  imports: [
12
  BrowserModule,
3
 
4
  import { AppRoutingModule } from './app-routing.module';
5
  import { AppComponent } from './app.component';
6
+ import { BookListComponent } from './book-list/book-list.component';
7
 
8
  @NgModule({
9
  declarations: [
10
+ AppComponent,
11
+ BookListComponent
12
  ],
13
  imports: [
14
  BrowserModule,
src/app/book-list/book-list.component.html ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1>Books</h1>
2
+ <ul class="book-list">
3
+ <li *ngFor="let book of books">
4
+ <div class="list-item">
5
+ <img *ngIf="book.thumbnailUrl" [src]="book.thumbnailUrl" alt="Cover">
6
+ <h2>{{ book.title }}</h2>
7
+ <p role="doc-subtitle" *ngIf="book.subtitle">
8
+ {{ book.subtitle }}
9
+ </p>
10
+ <ul class="comma-list">
11
+ <li *ngFor="let author of book.authors">
12
+ {{ author }}
13
+ </li>
14
+ </ul>
15
+ <div>ISBN {{ book.isbn }}</div>
16
+ </div>
17
+ </li>
18
+ <li *ngIf="!books.length">
19
+ No books available.
20
+ </li>
21
+ </ul>
src/app/book-list/book-list.component.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Component } from '@angular/core';
2
+
3
+ import { Book } from '../shared/book';
4
+
5
+ @Component({
6
+ selector: 'bm-book-list',
7
+ templateUrl: './book-list.component.html',
8
+ standalone: false,
9
+ styleUrl: './book-list.component.css'
10
+ })
11
+ export class BookListComponent {
12
+ books: Book[] = [];
13
+
14
+ constructor() {
15
+ this.books = [
16
+ {
17
+ isbn: '12345',
18
+ title: 'Tierisch gut kochen',
19
+ authors: ['Mrs Chimp', 'Mr Gorilla'],
20
+ published: '2022-06-20',
21
+ subtitle: 'Rezepte von Affe bis Zebra',
22
+ thumbnailUrl: 'https://cdn.ng-buch.de/kochen.png',
23
+ description: 'Immer lecker und gut'
24
+ },
25
+ {
26
+ isbn: '67890',
27
+ title: 'Backen mit Affen',
28
+ authors: ['Orang Utan'],
29
+ published: '2022-07-15',
30
+ subtitle: 'Bananenbrot und mehr',
31
+ thumbnailUrl: 'https://cdn.ng-buch.de/backen.png',
32
+ description: 'Tolle Backtipps für Mensch und Tier'
33
+ }
34
+ ];
35
+ }
36
+ }
src/app/shared/book.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ export interface Book {
2
+ isbn: string;
3
+ title: string;
4
+ authors: string[];
5
+ published?: string;
6
+ subtitle?: string;
7
+ thumbnailUrl?: string;
8
+ description?: string;
9
+ }