Custom star rating Angularjs

不问归期 提交于 2019-12-06 15:27:36

You'll need a condition for each star in your updateStars function, either as a property for each, or a separate array. Then, you can do something like this:

scope.hoveringOver = function(index){
    for (var i = 0; i <= index; i++) {
        scope.stars[i].Condition = "Good.png";
    }
};

Or the separate array way (assuming the array is scope.conditions):

scope.hoveringOver = function(index){
    for (var i = 0; i <= index; i++) {
        scope.conditions[i] = "Good.png";
    }
};

You also need a function opposite of hoveringOver to remove the states to default/previous versions.

Angular UI gives you premade directives for the same purpose, did you try it?

http://angular-ui.github.io/bootstrap/

Go down to the Rating Title in the same page, i think it might solve your purpose.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!