Introduction
E-Commerce Websites generally show ratings in the form of stars for each item. They provide maximum ratings up to five stars from one. Start making a very good visual effect in the representation of ratings of any item. It is very easy to show start in Web Applications.
Back-end gives JSON response, which contains Rating data for each item, as given below.
- {"items":[{"name":"Tommy Hilfiger backpack","price":"1350","rating":"3.8", {"name":"Redragon 3000DPI Mouse","rating":"4"}]}
Now, write below code into controller to make Stars,
Yellow Star formation
- controller.getYellowStars = function (num) {
- var numberOfStars = Math.round(num);
- if (numberOfStars > 5)
- numberOfStars = 5;
- var data = new Array(numberOfStars);
- for (var i = 0; i < data.length; i++) {
- data[i] = i;
- }
- return data;
- }
- controller.getGreyStars = function (num) {
- var numberOfStars = Math.round(num);
- var restStars = 5 - numberOfStars;
- if (restStars > 0) {
- var data = new Array(restStars);
- for (var i = 0; i < data.length; i++) {
- data[i] = i;
- }
- return data;
- }
- }
- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">

chaitanya phadnisPosted Oct 14, 2016, 1:05 AM
Please upload solution files.
Humayun Kabir MamunPosted Oct 13, 2016, 4:05 AM
Nice...