src/app/book-detail/comments/comments.component.ts
Component that displays the comments for a given book
selector | book-comments |
templateUrl | ./comments.component.html |
comments
|
Comments about the book This input property is passed down from the parent BookDetailComponent to this component.
Type: |
import { Component, Input } from '@angular/core';
/**
* Component that displays the comments for a given book
*/
@Component({
selector: 'book-comments',
templateUrl: './comments.component.html'
})
export class CommentsComponent {
/**
* Comments about the book
*
* This input property is passed down from the parent {@link BookDetailComponent}
* to this component.
*/
@Input() comments: string[];
}
<h3 class="h4">Comments</h3>
<ul class="list-group" *ngIf="comments && comments.length > 0; else noComments">
<li class="list-group-item" *ngFor="let comment of comments">{{ comment }}</li>
</ul>
<ng-template #noComments><em>No Comments</em></ng-template>