Currently utilizing the amazing Rating AngularJS library available at https://github.com/bandraszyk/awesome-rating I am interested in understanding how to retrieve the selected value and store it in my controller. The $scope.rating is returning undefined for me.
Controller:
app.controller('appctrl', function($scope, $http) {
$scope.optionst2 = {
values : [ "A", "B", "C", "D", "E"]
};
$scope.getratingvalue = function () {
console.log($scope.rating)
};
};
HTML:
<div class="awesomeRating" awesome-rating="rating" awesome-rating-options="optionst2" ng-click="getratingvalue()"></div>
<div class="awesomeRatingValue">
<span class="awesomeRatingValue" ng-bind="'Rating value: ' + rating"></span>
</div>
{{rating}}
I managed to find a solution that works perfectly, although it may not be the most optimal approach.
<div class="awesomeRating" awesome-rating="rating" awesome-rating-options="optionst2" ng-click="getratingvalue()"></div>
<span style="display: none;" id="getvall" ng-bind="rating" ng-value="rating" value="rating" ></span>
$scope.rating = "D";
$scope.optionst2 = {
values : [ "A", "B", "C", "D", "E"]
};
$scope.getratingvalue = function () {
setTimeout(
function()
{
console.log($("#getvall").val())
}, 50);
};