@@ -1,6 +1,7 @@
|
|
1 |
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
|
2 |
|
3 |
import { Book } from '../shared/book';
|
|
|
4 |
|
5 |
@Component({
|
6 |
selector: 'bm-book-list',
|
@@ -11,35 +12,10 @@
|
|
11 |
books: Book[];
|
12 |
@Output() showDetailsEvent = new EventEmitter<Book>();
|
13 |
|
|
|
|
|
14 |
ngOnInit() {
|
15 |
-
this.books =
|
16 |
-
{
|
17 |
-
isbn: '9783864906466',
|
18 |
-
title: 'Angular',
|
19 |
-
authors: ['Ferdinand Malcher', 'Johannes Hoppe', 'Danny Koppenhagen'],
|
20 |
-
published: new Date(2019, 4, 30),
|
21 |
-
subtitle: 'Grundlagen, fortgeschrittene Themen und Best Practices - mit NativeScript und NgRx',
|
22 |
-
rating: 5,
|
23 |
-
thumbnails: [{
|
24 |
-
url: 'https://ng-buch.de/buch1.jpg',
|
25 |
-
title: 'Buchcover'
|
26 |
-
}],
|
27 |
-
description: 'Die Autoren führen Sie mit einem anspruchsvollen Beispielprojekt durch die Welt von Angular...'
|
28 |
-
},
|
29 |
-
{
|
30 |
-
isbn: '9783864903274',
|
31 |
-
title: 'React',
|
32 |
-
authors: ['Oliver Zeigermann', 'Nils Hartmann'],
|
33 |
-
published: new Date(2016, 6, 17),
|
34 |
-
subtitle: 'Die praktische Einführung in React, React Router und Redux',
|
35 |
-
rating: 3,
|
36 |
-
thumbnails: [{
|
37 |
-
url: 'https://ng-buch.de/buch2.jpg',
|
38 |
-
title: 'Buchcover'
|
39 |
-
}],
|
40 |
-
description: 'React ist ein JavaScript-Framework zur Entwicklung von Benutzeroberflächen...'
|
41 |
-
}
|
42 |
-
];
|
43 |
}
|
44 |
|
45 |
showDetails(book: Book) {
|
1 |
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
|
2 |
|
3 |
import { Book } from '../shared/book';
|
4 |
+
import { BookStoreService } from '../shared/book-store.service';
|
5 |
|
6 |
@Component({
|
7 |
selector: 'bm-book-list',
|
12 |
books: Book[];
|
13 |
@Output() showDetailsEvent = new EventEmitter<Book>();
|
14 |
|
15 |
+
constructor(private bs: BookStoreService) { }
|
16 |
+
|
17 |
ngOnInit() {
|
18 |
+
this.books = this.bs.getAll();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
showDetails(book: Book) {
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Injectable } from '@angular/core';
|
2 |
+
|
3 |
+
import { Book } from './book';
|
4 |
+
|
5 |
+
@Injectable({
|
6 |
+
providedIn: 'root'
|
7 |
+
})
|
8 |
+
export class BookStoreService {
|
9 |
+
books: Book[];
|
10 |
+
|
11 |
+
constructor() {
|
12 |
+
this.books = [
|
13 |
+
{
|
14 |
+
isbn: '9783864906466',
|
15 |
+
title: 'Angular',
|
16 |
+
authors: ['Ferdinand Malcher', 'Johannes Hoppe', 'Danny Koppenhagen'],
|
17 |
+
published: new Date(2019, 4, 30),
|
18 |
+
subtitle: 'Grundlagen, fortgeschrittene Themen und Best Practices - mit NativeScript und NgRx',
|
19 |
+
rating: 5,
|
20 |
+
thumbnails: [{
|
21 |
+
url: 'https://ng-buch.de/buch1.jpg',
|
22 |
+
title: 'Buchcover'
|
23 |
+
}],
|
24 |
+
description: 'Die Autoren führen Sie mit einem anspruchsvollen Beispielprojekt durch die Welt von Angular...'
|
25 |
+
},
|
26 |
+
{
|
27 |
+
isbn: '9783864903274',
|
28 |
+
title: 'React',
|
29 |
+
authors: ['Oliver Zeigermann', 'Nils Hartmann'],
|
30 |
+
published: new Date(2016, 6, 17),
|
31 |
+
subtitle: 'Die praktische Einführung in React, React Router und Redux',
|
32 |
+
rating: 3,
|
33 |
+
thumbnails: [{
|
34 |
+
url: 'https://ng-buch.de/buch2.jpg',
|
35 |
+
title: 'Buchcover'
|
36 |
+
}],
|
37 |
+
description: 'React ist ein JavaScript-Framework zur Entwicklung von Benutzeroberflächen...'
|
38 |
+
}
|
39 |
+
];
|
40 |
+
}
|
41 |
+
|
42 |
+
getAll(): Book[] {
|
43 |
+
return this.books;
|
44 |
+
}
|
45 |
+
}
|