Open web-dave opened 7 years ago
ng g c books/book-preview
@Input() book;
@Output() bookselected = new EventEmitter();
<ul *ngIf="book">
<li>{{book.title}}</li>
<li>{{book.isbn}} <button (click)="selectThisBook()" class="btn btn-info">show me more</button></li>
</ul>
selectThisBook() {
this.bookselected.emit(this.book);
}
<div *ngIf="books">
<book-preview *ngFor="let book of books" [book]="book" (bookselected)="selectBook($event)"></book-preview>
</div>
selectBook(book) {
console.log(book);
}
book-preview
componentbook-preview
inbook-list
templatebook-preview
tobook.list