I am attempting to implement the jquery raty plugin for star rating using angularjs. To achieve this, I have created a custom directive as shown below:
app.directive("ngStars", function() {
return {
restrict: 'A',
link: function(scope, elem, attrs) {
$(elem).raty({
'path': base_url+'images',
score: attrs.score,
readOnly: true,
hints: ['سىء جدا', 'سىء', 'عادى', 'جديد', 'ممتاز'],
});
}
}
});
Here is my html code:
<div ng-repeat="place in places">
<div ng-stars class="star" score={{place.rate}}></div>
</div>
The plugin works when I manually set the score
attribute value like score="5"
. However, I need to dynamically set the score value using angularjs with score="{{place.rate}}"
, but it's not functioning as expected.
How can I resolve this issue?