Angularjs Rendering using command star rating system example, angularjsusing

Source: Internet
Author: User

Angularjs Rendering using command star rating system example, angularjsusing

This article describes an example of the Star Rating System of the using command rendered by Angularjs. The details are as follows:
I am trying to create a star rating system that uses angularjs/ion statically with little effect. But at present, nothing is output to the screen... am I doing wrong?

Service.html

 <ion-list>  <ion-item ng-repeat="business in businessList track by $index" class="item-icon-right">   

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);});

Solution 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   };

And also modify service.html

<div star-rating rating-value="rating.current" max="rating.max"></div>

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.