angularjs - bootstrap star rating in angular js -


i able number database , display in .html as

<tr ng-repeat="review in reviews ">           <td>{{review.reviewer}}</td>           <td>{{review.comment}}</td>           <td>{{review.rating}}</td> 

here, {{review.rating}} given number.

how use bootstrap display star rating given number?

you can use angularjs bootstrap ui directive:

https://angular-ui.github.io/bootstrap/

-> rating (ui.bootstrap.rating)

example: http://plnkr.co/edit/wpfxg0zqslhptqvbhdgi?p=preview

index.html

<div ng-controller="ratingdemoctrl">     <h4>rating</h4>     <uib-rating ng-model="rate" max="max" read-only="isreadonly" on-hover="hoveringover(value)" on-leave="overstar = null" titles="['one','two','three']" aria-labelledby="default-rating"></uib-rating>         <span class="label" ng-class="{'label-warning': percent<30, 'label-info': percent>=30 && percent<70, 'label-success': percent>=70}" ng-show="overstar && !isreadonly">{{percent}}%</span> </div> 

app.js

angular.module('ui.bootstrap.demo', ['nganimate', 'ui.bootstrap']); angular.module('ui.bootstrap.demo').controller('ratingdemoctrl', function ($scope) {   $scope.rate = 7;   $scope.max = 10;   $scope.isreadonly = false;    $scope.hoveringover = function(value) {     $scope.overstar = value;     $scope.percent = 100 * (value / $scope.max);   };  }); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -