Code Monkey home page Code Monkey logo

ng-rating's Introduction

ng-rating

Angular directive to display "stars" (or something else) based ratings

Get Started

First, you need to include the scripts and css in your page

<link href="ng-rating.css" rel="styletheet" type="text/css" />
<!-- optional font-awesome to have access to icons -->
<link href="font-awesome.css" rel="styletheet" type="text/css" />

<script src="angular.js"></script>
<script src="ng-rating.js"></script>

Then you have to specify the "ngRating" module as dependency of your angular app

var myApp = angular.module('myAwesomeApp', ['ngRating']);

Finaly you can use the ng-rating directive to display ratings like so

<ng-rating ng-model="hotel.rating"></ng-rating>

See the index.html file for full sample

Attributes

The directive accept different attributes :

  • ng-model : REQUIRED : specify the actual rating value
  • start-count : the number of stars to display (default : 5)
  • based-on : the value on witch the calculation will be made. 5 stars based on 100 mean 1 active star = 20, etc...
  • editable : specify if the user can change the rating by clicking on the stars
  • icon-class : specify the class that will specify with icon to display for each stars (by default : fa fa-star)
  • show-grade : specify if the grade (rating number) is displayed or not after the stars

Classes

These are the diferent classes that are applied

  • ng-rating : The container
    • ng-rating--xlow : Applied on the container when the rating level is extra-low
    • ng-rating--low : Applied on the container when the rating level is low
    • ng-rating--medium : Applied on the container when the rating level is medium
    • ng-rating--high : Applied on the container when the rating level is high
    • ng-rating--xhigh : Applied on the container when the rating level is exta-high
    • ng-rating--editable : Applied on the container when the rating is editable
  • ng-rating-group : The group of stars
    • ng-rating-group--hover : The group of stars that will be active (the width of this element will be set by the directive)
  • ng-rating-star : The star that contain a "i" tag
    • ng-rating-star--active : Applies on the stars that are active

ng-rating's People

Contributors

lpillonel avatar engincancan avatar olivierbossel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.