将排名号码更改为开始
changing ranking number to starts
我需要把我的排名改成星号
我使用了以下代码:
http://jsfiddle.net/AhakQ/13/
但是当排名为零时 - 我根本看不到星星
在此示例中,当
$scope.ratings = [{
current: 0,
max: 10
}, {
current: 3,
max: 5
}];
如何更改?
这就是我想要改变的
var updateStars = function () {
scope.stars = [];
var isempty = 1;
for (var i = 0; i < scope.max; i++) {
scope.stars.push({
filled: i < scope.ratingValue
});
isempty = 0;
}
if(isempty == 1)
{
scope.stars.push({
rating: i < scope.ratingValue
});
}
};
在您的 $watch
中,您遇到的条件 if(newVal)
首先不允许 0
创建星星。 :)
情况可能是这样的:
scope.$watch('ratingValue', function (oldVal, newVal) {
if (angular.isDefined(newVal)) {
updateStars();
}
});
我需要把我的排名改成星号 我使用了以下代码: http://jsfiddle.net/AhakQ/13/
但是当排名为零时 - 我根本看不到星星 在此示例中,当
$scope.ratings = [{
current: 0,
max: 10
}, {
current: 3,
max: 5
}];
如何更改?
这就是我想要改变的
var updateStars = function () {
scope.stars = [];
var isempty = 1;
for (var i = 0; i < scope.max; i++) {
scope.stars.push({
filled: i < scope.ratingValue
});
isempty = 0;
}
if(isempty == 1)
{
scope.stars.push({
rating: i < scope.ratingValue
});
}
};
在您的 $watch
中,您遇到的条件 if(newVal)
首先不允许 0
创建星星。 :)
情况可能是这样的:
scope.$watch('ratingValue', function (oldVal, newVal) {
if (angular.isDefined(newVal)) {
updateStars();
}
});