34 lines
819 B
TypeScript
34 lines
819 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({
|
|
next: (data) => {
|
|
this.count = +data;
|
|
}
|
|
});
|
|
} else if (this.target) {
|
|
this.commentService.count(this.target).subscribe({
|
|
next: (data) => {
|
|
this.count = +data;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|