javascript - Insert value into jk-rating-stars element using angularJS -
hello know how put value rating="ctrl.rating" $scope angular js.
<jk-rating-stars max-rating="5" rating="ctrl.rating" read-only="ctrl.readonly" on-rating="ctrl.onrating(rating)"> </jk-rating-stars>
thanks
<div ng-app="myapp" ng-controller="myctrl ctrl"> <jk-rating-stars max-rating="5" rating="ctrl.rating" read-only="ctrl.readonly" on-rating="ctrl.onrating(rating)"> </jk-rating-stars> </div>
angular.module('myapp', ['ngmaterial', 'jkangularratingstars']) .controller('myctrl', function() { this.rating = 3; this.readonly = false; this.onrating = function(rating){ alert('on rating: ' + rating); }; });
the demo
angular.module('myapp', ['ngmaterial', 'jkangularratingstars']) .controller('myctrl', function() { this.rating = 3; this.readonly = false; this.onrating = function(rating){ console.log('on rating: ' + rating); }; });
<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 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>
Comments
Post a Comment