再过一两夜,秋霜在月下布满山谷,然后退回到北面群山那边稍作停留,好让金黄的初秋温柔地抚慰大地。轻微的茴香气息弥漫在天空中。还有金菊的芬芳气味。雾气翻腾,被九月的月色冲破,露出一片蔚蓝色的天空。
本文介绍Angularjs渲染的 using 指令的星级评分系统示例,分享给大家,具体如下:
我试图创建静态使用 angularjs/离子成效甚微的星级评分系统。但目前什么都不输出到屏幕上......我是我做错了吗?
service.html
<ion-list> <ion-item ng-repeat="business in businessList track by $index" class="item-icon-right"> <h2>{{business.name}}</h2> {{business.distance}} miles <br> <div star-rating rating-value="{{business.rating}}" max="rating.max"></div> <i class="icon ion-chevron-right icon-accessory"></i> </ion-item> </ion-list>
directives.js
angular.module('starter.directives', []) .directive('starRating', function() { return { restrict: 'A', template: '<ul class="rating">' + '<li ng-repeat="star in stars" ng-class="star">' + '\u2605' + '</li>' + '</ul>', 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
.service("BusinessData", [function () { var businessData = [ { id: 1, serviceId: 1, name: 'World Center Garage', distance: 0.1, rating: 4 } ]; 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; } } }])
controller.js
.controller('ServiceCtrl', function($scope, ServicesData, BusinessData, $stateParams) { $scope.service = ServicesData.getSelectedService($stateParams.service); $scope.businessList = BusinessData.getSelectedBusiness($stateParams.service); });
解决方法 1:
controller.js
.controller('ServiceCtrl', function($scope, ServicesData, BusinessData, $stateParams) { $scope.service = ServicesData.getSelectedService($stateParams.service); $scope.businessList = BusinessData.getSelectedBusiness($stateParams.service); $scope.ratings = { current: 5, max: 10 };
和也修改service.html
<div star-rating rating-value="rating.current" max="rating.max"></div>
以上就是Angularjs渲染的 using 指令的星级评分系统示例。做人要当提起时提起,当放下时放下。功名富贵放不下,生命就在功名富贵里耗费;悲欢离合放不下,生命就在悲欢离合里挣扎;放不下金钱,放不下名位,放不下人情,生命就在金钱名位人情里打滚;对是非放不下,对得失放不下,对善恶放不下,生命就在是非、善恶、得失里面,不得安宁。更多关于Angularjs渲染的 using 指令的星级评分系统示例请关注haodaima.com其它相关文章!