本文介绍Angularjs渲染的 using 指令的星级评分系统示例,分享给大家,具体如下: 我试图创建静态使用 angularjs/离子成效甚微的星级评分系统。但目前什么都不输出到屏幕上......我是我做错了吗?
service.html
directives.js
.directive('starRating',function() {
return {
restrict: 'A',template: '<ul class="rating">' +
'<li ng-repeat="star in stars" ng-class="star">' +
'\u2605' +
'' +
'',scope: {
ratingValue: '=',max: '='
},link: function(scope,elem,attrs) {
scope.stars = [];
for (var i = 0; i < scope.max; i++) {
scope.stars.push({
filled: i < scope.rating
});
}
}
}
});
return {
restrict: 'A',template: '<ul class="rating">' +
'<li ng-repeat="star in stars" ng-class="star">' +
'\u2605' +
'' +
'',scope: {
ratingValue: '=',max: '='
},link: function(scope,elem,attrs) {
scope.stars = [];
for (var i = 0; i < scope.max; i++) {
scope.stars.push({
filled: i < scope.rating
});
}
}
}
});
services.js
return {
getAllBusinesses: function () {
return businessData;
},getSelectedBusiness: function(serviceId) {
var businessList = [];
serviceId = parseInt(serviceId);
for(i=0;i<businessData.length;i++) {
if(businessData[i].serviceId === serviceId) {
businessList.push(businessData[i]);
}
}
return businessList;
}
}
}])
getAllBusinesses: function () {
return businessData;
},getSelectedBusiness: function(serviceId) {
var businessList = [];
serviceId = parseInt(serviceId);
for(i=0;i<businessData.length;i++) {
if(businessData[i].serviceId === serviceId) {
businessList.push(businessData[i]);
}
}
return businessList;
}
}
}])
controller.js
解决方法 1:
controller.js
和也修改service.html