I am trying to display stars for each item in a list
I have an interface that has the 5-star score on a video, how do I do a foreach for the count of that score? rather than creating an array for the score?
interface Video{
Score: number;
}
<td>
<span data-bind="foreach: score">
<span class="glyphicon-star"></span>
</span>
<span data-bind="foreach: 5 - score">
<span class="glyphicon-star-empty"></span>
</span>
</td>
You could either use
Array.from()or theArray(score)to create an array from the scoreor
(Use
score()if it's anobservable)Here's a minimal snippet: