There’s no automatic way to do this in ionic or anywhere for that matter. But you can simulate the star rating by applying the following logic:
Run a function called calulateStar(taq_review_score) like so
Multiply the taq_review_score by 100 (and then multiply by 5), then round down to get the closest integer value (in this case that would 4)
Run an loop for the view that outputs/renders a star icon based on the value from (1) which in this case should output 4 html star icons. then add the actual numerical value beside it (82.2857…)
parseFloat (for conversion to a floating-point number) or
parseInt (for string-to-integer conversion).
parseFloat syntax: parseFloat(string)
How it works:
The argument of parseFloat must be a string or a string expression. The result of parseFloat is the number whose decimal representation was contained in that string (or the number found in the beginning of the string). If the string argument cannot be parsed as a decimal number, the result will be NaN (not-a-number value).
Examples (comments in each line give the conversion results):
$scope.max = 5;
$scope.calStar = function(taq_review_score){
$scope.rate = parseFloat(taq_review_score)/20;
console.log($scope.rate); // for example, 82/100 point will be converted to 4 for 4/5 stars rating
return $scope.rate;
}
And this is the problem: It ALWAYS show 5 Stars, not the correct number of stars i want (you know, it’s a rating system).