BookMonkey 4 Diff

Files changed (5) hide show
  1. tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/app.component.ts +0 -1
  2. tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/book-details/book-details.component.html +0 -1
  3. tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/book-details/book-details.component.ts +0 -1
  4. tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/book-list/book-list.component.ts +4 -28
  5. tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/shared/book-store.service.ts +45 -0
tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/app.component.ts RENAMED
@@ -10,7 +10,6 @@
10
  styleUrls: ['./app.component.css']
11
  })
12
  export class AppComponent {
13
-
14
  book?: Book;
15
  viewState: ViewState = 'list';
16
   
10
  styleUrls: ['./app.component.css']
11
  })
12
  export class AppComponent {
   
13
  book?: Book;
14
  viewState: ViewState = 'list';
15
   
tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/book-details/book-details.component.html RENAMED
@@ -17,7 +17,6 @@
17
  <h4>Erschienen</h4>
18
  {{ book.published }}
19
  </div>
20
-
21
  <div class="four wide column" *ngIf="book.rating">
22
  <h4>Rating</h4>
23
  <i class="yellow star icon"
17
  <h4>Erschienen</h4>
18
  {{ book.published }}
19
  </div>
   
20
  <div class="four wide column" *ngIf="book.rating">
21
  <h4>Rating</h4>
22
  <i class="yellow star icon"
tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/book-details/book-details.component.ts RENAMED
@@ -8,7 +8,6 @@
8
  styleUrls: ['./book-details.component.css']
9
  })
10
  export class BookDetailsComponent implements OnInit {
11
-
12
  @Input() book?: Book;
13
  @Output() showListEvent = new EventEmitter<any>();
14
   
8
  styleUrls: ['./book-details.component.css']
9
  })
10
  export class BookDetailsComponent implements OnInit {
   
11
  @Input() book?: Book;
12
  @Output() showListEvent = new EventEmitter<any>();
13
   
tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/book-list/book-list.component.ts RENAMED
@@ -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(): void {
15
- this.books = [
16
- {
17
- isbn: '9783864907791',
18
- title: 'Angular',
19
- authors: ['Ferdinand Malcher', 'Johannes Hoppe', 'Danny Koppenhagen'],
20
- published: new Date(2020, 8, 1),
21
- subtitle: 'Grundlagen, fortgeschrittene Themen und Best Practices',
22
- rating: 5,
23
- thumbnails: [{
24
- url: 'https://ng-buch.de/angular-cover.jpg',
25
- title: 'Buchcover'
26
- }],
27
- description: 'Lernen Sie Angular mit diesem Praxisbuch!'
28
- },
29
- {
30
- isbn: '9783864905520',
31
- title: 'React',
32
- authors: ['Oliver Zeigermann', 'Nils Hartmann'],
33
- published: new Date(2019, 11, 12),
34
- subtitle: 'Grundlagen, fortgeschrittene Techniken und Praxistipps',
35
- rating: 3,
36
- thumbnails: [{
37
- url: 'https://ng-buch.de/react-cover.jpg',
38
- title: 'Buchcover'
39
- }],
40
- description: 'Das bewährte und umfassende Praxisbuch zu React.'
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(): void {
18
+ this.books = this.bs.getAll();
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
19
  }
20
   
21
  showDetails(book: Book) {
tmp/src/app/book-monkey/{iteration-1/event-bindings → iteration-2/di}/shared/book-store.service.ts RENAMED
@@ -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: '9783864907791',
15
+ title: 'Angular',
16
+ authors: ['Ferdinand Malcher', 'Johannes Hoppe', 'Danny Koppenhagen'],
17
+ published: new Date(2020, 8, 1),
18
+ subtitle: 'Grundlagen, fortgeschrittene Themen und Best Practices',
19
+ rating: 5,
20
+ thumbnails: [{
21
+ url: 'https://ng-buch.de/angular-cover.jpg',
22
+ title: 'Buchcover'
23
+ }],
24
+ description: 'Lernen Sie Angular mit diesem Praxisbuch!'
25
+ },
26
+ {
27
+ isbn: '9783864905520',
28
+ title: 'React',
29
+ authors: ['Oliver Zeigermann', 'Nils Hartmann'],
30
+ published: new Date(2019, 11, 12),
31
+ subtitle: 'Grundlagen, fortgeschrittene Techniken und Praxistipps',
32
+ rating: 3,
33
+ thumbnails: [{
34
+ url: 'https://ng-buch.de/react-cover.jpg',
35
+ title: 'Buchcover'
36
+ }],
37
+ description: 'Das bewährte und umfassende Praxisbuch zu React.'
38
+ }
39
+ ];
40
+ }
41
+  
42
+ getAll(): Book[] {
43
+ return this.books;
44
+ }
45
+ }