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

34 lines
771 B
TypeScript

import { Component, OnInit, Input } from '@angular/core';
import { VoteService } from '../../services/vote.service';
@Component({
selector: 'ui-points',
templateUrl: './points.ui.html',
styleUrls: ['./points.ui.scss']
})
export class UiPoints implements OnInit {
count: number;
@Input() target: number;
@Input() type: string;
constructor(private voteService: VoteService) { }
ngOnInit(): void {
if (this.type == 'e') {
this.voteService.getEntryPoints(this.target).subscribe({
next: (data) => {
this.count = +data;
}
});
} else if (this.type == 'c') {
this.voteService.getCommentPoints(this.target).subscribe({
next: (data) => {
this.count = +data;
}
});
}
}
}