<div ng-app="myApp" ng-controller="MyCtrl as ctrl">
<jk-rating-stars max-rating="5" rating="ctrl.rating"
read-only="ctrl.readOnly" on-rating="ctrl.onRating(rating)">
</jk-rating-stars>
</div>
Here is the code for initializing Angular and setting up a controller:
angular.module('myApp', ['ngMaterial', 'jkAngularRatingStars'])
.controller('MyCtrl', function() {
this.rating = 3;
this.readOnly = false;
this.onRating = function(rating){
alert('On Rating: ' + rating);
};
});
This demo includes the necessary script tags and links to external resources:
<script src="//unpkg.com/angular/angular.js"></script>
<script src="//unpkg.com/angular-animate/angular-animate.js"></script>
<script src="//unpkg.com/angular-aria/angular-aria.js"></script>
<script src="https://unpkg.com/angular-material/angular-material.js"></script>
<link rel="stylesheet" href="https://unpkg.com/angular-material/angular-material.css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/angular-jk-rating-stars/dist/jk-rating-stars.css" />
<script src="https://unpkg.com/angular-jk-rating-stars/dist/jk-rating-stars.js"></script>
<body ng-app="myApp" ng-controller="MyCtrl as ctrl">
<jk-rating-stars max-rating="5" rating="ctrl.rating"
read-only="ctrl.readOnly" on-rating="ctrl.onRating(rating)">
</jk-rating-stars>
<br>
<input type="number" ng-model="ctrl.rating" />
</body>