Need help with modifying star images based on ratings? I have two PNG files, one with an empty star and one with a full star. My goal is to dynamically adjust the number of stars displayed depending on the rating given, which ranges from 1 to 5. However, my current code isn't functioning as expected:
<div>
<img ng-repeat="i in getNumberOfFullStars(company.AverageReview)" ng-src="{{starPhoto}}">
<img ng-repeat="i in getNumberOfEmptyStars(company.AverageReview)" ng-src="{{emptyPhoto}}">
</div>
JavaScript Code Snippet:
$scope.getNumberOfFullStars = function(num){
return new Array(num);
};
$scope.getNumberOfEmptyStars = function(num){
var emptyCount = 5-num;
return new Array(emptyCount);
};
If you have any insights or suggestions, I would greatly appreciate your assistance. Thank you!