import { Component, Input, OnInit } from '@angular/core'; import { CommentService } from '../../services/comment.service'; @Component({ standalone: false, 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({ next: (data) => { this.count = +data; } }); } else if (this.target) { this.commentService.count(this.target).subscribe({ next: (data) => { this.count = +data; } }); } } }