From 25abd00a4c6cf050afe1ae5f1be535b9fcc359bf Mon Sep 17 00:00:00 2001 From: csimonis Date: Tue, 24 Sep 2024 08:34:17 +0200 Subject: [PATCH] fix rating --- src/app/star/star.component.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/star/star.component.ts b/src/app/star/star.component.ts index 6c9e940..ac62cf6 100644 --- a/src/app/star/star.component.ts +++ b/src/app/star/star.component.ts @@ -6,13 +6,11 @@ import {Component, Input} from '@angular/core'; imports: [], template: ` @for (_ of getList(); track null) { - test - + } @if (rating % 1 >= 0.5) { - + } - `, }) export class StarComponent { @@ -20,8 +18,11 @@ export class StarComponent { public rating: number = 0; public getList(): null[] { - console.log(this.rating) - console.log(Array(this.rating).fill(null)) - return Array(this.rating).fill(null); + let rating = this.rating; + if (rating % 1 !== 0) { + rating = this.rating - 0.5; + } + + return Array(rating).fill(null); } }