import { Component , EventEmitter , Input , Output , OnInit , OnDestroy } from '@angular/core' ; import { Comment , User , UserService } from '../core' ; import { Subscription } from 'rxjs' ; @ Component ( { selector : 'app-article-comment' , templateUrl : './article-comment.component.html' } ) export class ArticleCommentComponent implements OnInit , OnDestroy { constructor ( private userService ) { } private subscription : Subscription ; @ Input ( ) comment : Comment ; @ Output ( ) deleteComment = new EventEmitter < boolean > ( ) ; canModify : boolean ; ngOnInit ( ) { this . subscription = this . userService . currentUser . subscribe ( ( userData ) => { this . canModify = ( userData . username === this . comment . author . username ) ; } ) ; } ngOnDestroy ( ) { this . subscription . unsubscribe ( ) ; } deleteClicked ( ) { this . deleteComment . emit ( true ) ; } }