Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ngOnInit(): void {
- this.subscriptionGetRating = this.ratingService.getRating(this.userId).subscribe( data => {
- this.count = data['count'];
- this.rating = data['rating'] / this.count;
- if(this.count == 0){
- this.rating = 0;
- for(let k=0;k<=4;k++){
- this.ratingArray[k] = this.greyStar;
- }
- } else{
- let trunc = Math.trunc(this.rating);
- for(let j=0;j<trunc+1;j++){
- if(this.rating>j && this.rating<j+1){
- this.ratingArray[j] = this.midStar;
- }else {
- if(j!=trunc)
- this.ratingArray[j] = this.yellowStar;
- }
- }
- if (this.rating == Math.floor(this.rating)){
- for(let k=trunc;k<=4;k++){
- this.ratingArray[k] = this.greyStar;
- }
- } else {
- for(let k=trunc+1;k<=4;k++){
- this.ratingArray[k] = this.greyStar;
- }
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement