Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value on click from Angular UI Rating Directive

Using this Code here: plunkr

How would I write the value on click to the console? It seems as though this will only work in a form submit environment, but I'm hoping I'm wrong.

Note that the rating element is converted into several i elements in a span, and each i has an ng-click applied to it already.

To summarize - When I select a star, spit out the value selected to the console.

like image 402
Dakine83 Avatar asked Feb 16 '26 04:02

Dakine83


1 Answers

Rating supports ng-click:

<rating value="rate" max="max" readonly="isReadonly" 
    on-hover="hoveringOver(value)" on-leave="overStar = null" 
    ng-click="setRating()"></rating>

In your controller, simply add:

$scope.setRating = function() {
    alert($scope.rate);
};
like image 101
Rich Bennema Avatar answered Feb 19 '26 01:02

Rich Bennema