not working on ng-repeat
bug on ng-repeat not updating the stars
did you solve it? I am trying to put it in ng repeat each with different rating
ng-collection isn't working but ng-repeat will work
2016-08-17 1:14 GMT+03:00 missakation [email protected]:
did you solve it? I am trying to put it in ng repeat each with different rating
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fraserxu/ionic-rating/issues/35#issuecomment-240256377, or mute the thread https://github.com/notifications/unsubscribe-auth/ALfdQ5WHHerylyo44BW9_mV8wXUZaIRcks5qgjYsgaJpZM4Is74J .
Its working for me what should you do
In Your ionic-ratings tag add rating field and then change the code of rating controller as following:
<ionic-ratings ratingsobj='ratingsObject' rating='3' index='0' ></ionic-ratings>
And In Your Controller Add the Code which is following:
scope: { ratingsObj: '=ratingsobj', index: '=index', rating: '=rating'
},
link: function(scope, element, attrs) {
//Setting the default values, if they are not passed
scope.iconOn = scope.ratingsObj.iconOn || 'ion-ios-star';
scope.iconOff = scope.ratingsObj.iconOff || 'ion-ios-star-outline';
scope.iconOnColor = scope.ratingsObj.iconOnColor || 'rgb(200, 200, 100)';
scope.iconOffColor = scope.ratingsObj.iconOffColor || 'rgb(200, 100, 100)';
//scope.rating = scope.ratingsObj.rating || 0;
scope.minRating = scope.ratingsObj.minRating || 0;
scope.readOnly = scope.ratingsObj.readOnly || false;
scope.index = scope.index || 0;
scope.rating = scope.rating || 0;
//Setting the color for the icon, when it is active
scope.iconOnColor = {
color: scope.iconOnColor
};
//Setting the color for the icon, when it is not active
scope.iconOffColor = {
color: scope.iconOffColor
};
//Setting the rating
scope.rating = (scope.rating > scope.minRating) ? scope.rating : scope.minRating;
//Setting the previously selected rating
scope.prevRating = 0;
//scope.$watch('ratingsObj.rating', function(newValue, oldValue) {
scope.$watch('rating', function(newValue, oldValue) {
setRating(newValue);
});
function setRating(val, uiEvent) {
if (scope.minRating !== 0 && val < scope.minRating) {
scope.rating = scope.minRating;
} else {
scope.rating = val;
}
scope.prevRating = val;
if (uiEvent) scope.ratingsObj.callback(scope.rating, scope.index);
}
//Called when he user clicks on the rating
scope.ratingsClicked = function(val) {
setRating(val, true);
};
//Called when he user un clicks on the rating
scope.ratingsUnClicked = function(val) {
if (scope.minRating !== 0 && val < scope.minRating) {
scope.rating = scope.minRating;
} else {
scope.rating = val;
}
if (scope.prevRating == val) {
if (scope.minRating !== 0) {
scope.rating = scope.minRating;
} else {
scope.rating = 0;
}
}
scope.prevRating = val;
scope.ratingsObj.callback(scope.rating, scope.index);
};
}
};
}`
So It will display different stars
<div class="rate-right" ng-repeat="order in orders" ><ionic-ratings ratingsobj='ratingsObject' rating='order.rt_rate' index='0' ></ionic-ratings></div>