Git Product home page Git Product logo

angular-rateit's Introduction

angular-rateit

This directive was inspired by the jQuery (star)rating plugin RateIt. However this package will work without jQuery and is super light weight: 3.3 Kb minified 1.9 Kb.

Getting Started

You can install an angular-rateit package very easily using Bower:

bower install angular-rateit

Or add the files manually to your index file:

<link rel="stylesheet" href="angular-rateit/dist/rateit.css" />
<script src="angular-rateit/dist/rateit.js"></script>

Finally add 'ngRateIt' to your main module's list of dependencies:

angular.module('myApp', [
	...
    'ngRateIt',
    ...
]);

How to use

To get it working simply add this block of code to your view:

<ng-rate-it ng-model="test.rateit"></ng-rate-it>

For more advanced functionality you can add a couple attributes:

<ng-rate-it 
	ng-model = "String, Number, Array"
	min = "Double"
	max = "Double"
	step = "Double"
	readonly = "Boolean"
	ispreset = "Boolean"
	resetable = "Boolean"
	starwidth = "Integer"
	starheight = "Integer"
	rated = "Function"
	reset = "Function"
	over = "Function"
	beforerated = "Function: return promise"
	beforereset = "Function: return promise"
	>
</ng-rate-it>

Attributes

Attribute Description Value Default
ng-model Object bound to control. (Required) String, Number, Array -
min Minimal value. Double 0
max Maximal value. The difference between min and max will provide the number of stars. Double 5
step Step size. Double 0.5
readonly Whether or not is readonly. Boolean false
ispreset Whether or not the current value is the initial value. Boolean true
resetable When not readonly, whether to show the reset button. Boolean true
starwidth Width of the star picture. Integer 16
starheight Height of the star picture. Integer 16
rated Fired when a rating happened. (Obtain the rated value by the model) Function -
reset Fired when the reset button was clicked. Function -
over Fired when hovering over the element. First function parameter is the event, second parameter will contain the hover rating value. Function -
beforerated Fired before the item is actually rated. By rejecting the promise it is possible to cancel the rating. Function: return promise -
beforereset Fired before the item is actually reset. By rejecting the promise it is possible to cancel the reset. Function: return promise -

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.