|
@@ -1,5 +1,6 @@
|
|
| 1 |
import { Component, EventEmitter, Output } from '@angular/core';
|
| 2 |
|
|
|
|
| 3 |
import { Book } from '../../shared/book';
|
| 4 |
|
| 5 |
@Component({
|
|
@@ -12,27 +13,8 @@ export class BookListComponent {
|
|
| 12 |
books: Book[] = [];
|
| 13 |
@Output() selectBook = new EventEmitter<Book>();
|
| 14 |
|
| 15 |
-
constructor() {
|
| 16 |
-
this.books =
|
| 17 |
-
{
|
| 18 |
-
isbn: '12345',
|
| 19 |
-
title: 'Tierisch gut kochen',
|
| 20 |
-
authors: ['Mrs Chimp', 'Mr Gorilla'],
|
| 21 |
-
published: '2022-06-20',
|
| 22 |
-
subtitle: 'Rezepte von Affe bis Zebra',
|
| 23 |
-
thumbnailUrl: 'https://cdn.ng-buch.de/kochen.png',
|
| 24 |
-
description: 'Immer lecker und gut'
|
| 25 |
-
},
|
| 26 |
-
{
|
| 27 |
-
isbn: '67890',
|
| 28 |
-
title: 'Backen mit Affen',
|
| 29 |
-
authors: ['Orang Utan'],
|
| 30 |
-
published: '2022-07-15',
|
| 31 |
-
subtitle: 'Bananenbrot und mehr',
|
| 32 |
-
thumbnailUrl: 'https://cdn.ng-buch.de/backen.png',
|
| 33 |
-
description: 'Tolle Backtipps für Mensch und Tier'
|
| 34 |
-
}
|
| 35 |
-
];
|
| 36 |
}
|
| 37 |
|
| 38 |
doSelect(book: Book) {
|
| 1 |
import { Component, EventEmitter, Output } from '@angular/core';
|
| 2 |
|
| 3 |
+
import { BookStoreService } from '../../shared/book-store.service';
|
| 4 |
import { Book } from '../../shared/book';
|
| 5 |
|
| 6 |
@Component({
|
| 13 |
books: Book[] = [];
|
| 14 |
@Output() selectBook = new EventEmitter<Book>();
|
| 15 |
|
| 16 |
+
constructor(private service: BookStoreService) {
|
| 17 |
+
this.books = this.service.getAll();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
doSelect(book: Book) {
|
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Injectable } from '@angular/core';
|
| 2 |
+
|
| 3 |
+
import { Book } from './book';
|
| 4 |
+
|
| 5 |
+
@Injectable({
|
| 6 |
+
providedIn: 'root'
|
| 7 |
+
})
|
| 8 |
+
export class BookStoreService {
|
| 9 |
+
private books: Book[] = [];
|
| 10 |
+
|
| 11 |
+
constructor() {
|
| 12 |
+
this.books = [
|
| 13 |
+
{
|
| 14 |
+
isbn: '12345',
|
| 15 |
+
title: 'Tierisch gut kochen',
|
| 16 |
+
authors: ['Mrs Chimp', 'Mr Gorilla'],
|
| 17 |
+
published: '2022-06-20',
|
| 18 |
+
subtitle: 'Rezepte von Affe bis Zebra',
|
| 19 |
+
thumbnailUrl: 'https://cdn.ng-buch.de/kochen.png',
|
| 20 |
+
description: 'Immer lecker und gut'
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
isbn: '67890',
|
| 24 |
+
title: 'Backen mit Affen',
|
| 25 |
+
authors: ['Orang Utan'],
|
| 26 |
+
published: '2022-07-15',
|
| 27 |
+
subtitle: 'Bananenbrot und mehr',
|
| 28 |
+
thumbnailUrl: 'https://cdn.ng-buch.de/backen.png',
|
| 29 |
+
description: 'Tolle Backtipps für Mensch und Tier'
|
| 30 |
+
}
|
| 31 |
+
];
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
getAll(): Book[] {
|
| 35 |
+
return this.books;
|
| 36 |
+
}
|
| 37 |
+
}
|