bstlboard-front/src/app/ui/commentcount/commentcount.ui.ts

30 lines
765 B
TypeScript

import { Component, OnInit, Input } from '@angular/core';
import { CommentService } from '../../services/comment.service';
@Component({
selector: 'ui-commentcount',
templateUrl: './commentcount.ui.html',
styleUrls: [ './commentcount.ui.scss' ]
})
export class UiCommentCount implements OnInit {
count: number;
@Input() target: number;
@Input() parent: number;
constructor(private commentService: CommentService) { }
ngOnInit(): void {
if (this.target && this.parent) {
this.commentService.countParent(this.target, this.parent).subscribe((data) => {
this.count = +data;
});
} else if (this.target) {
this.commentService.count(this.target).subscribe((data) => {
this.count = +data;
});
}
}
}