Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-rateit

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-rateit

This directive was inspired by the jQuery (star)rating plugin [RateIt](http://rateit.codeplex.com/). However this package will work without jQuery and is very light weight.

  • 4.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

angular-rateit

This directive was inspired by the jQuery (star)rating plugin RateIt. However this package will work without jQuery and is very light weight.

ng-rate-it

Live demo

Getting Started

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

bower install angular-rateit

And add the files to your index page:

<link rel="stylesheet" href="angular-rateit/dist/ng-rateit.css" />
<script src="angular-rateit/dist/ng-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>

N.B. When using angular 1.2.* use <div ng-rate-it ng-model="test.rateit"></div>

For more advanced functionality you can add a couple attributes:

<ng-rate-it 
	ng-model = "String, Number, Array"
	min = "Double"
	max = "Double"
	step = "Double"
	read-only = "Boolean"
	pristine = "Boolean"
	resetable = "Boolean"
	star-width = "Integer"
	star-height = "Integer"
	rated = "Function(rating)"
	reset = "Function(rating)"
	before-rated = "Function(newRating): return promise"
	before-reset = "Function(rating): return promise"
	>
</ng-rate-it>

Attributes

AttributeDescriptionValueDefault
ng-modelObject bound to control. (Required)String, Number, Array-
minMinimal value.Double0
maxMaximal value. The difference between min and max will provide the number of stars.Double5
stepStep size.Double0.5
read-onlyWhether or not is readonly.Booleanfalse
pristineWhether or not the current value is the initial value.Booleantrue
resetableWhen not readonly, whether to show the reset button.Booleantrue
star-widthWidth of the star picture.Integer16
star-heightHeight of the star picture.Integer16
cancel-widthWidth of the cancel icon.Integerstar-width
cancel-heightHeight of the cancel icon.Integerstar-height
ratedFired when a rating happened. (Obtain the rated value by the model)Function-
resetFired when the reset button was clicked.Function-
before-ratedFired before the item is actually rated. By rejecting the promise it is possible to cancel the rating.Function: return promise-
before-resetFired before the item is actually reset. By rejecting the promise it is possible to cancel the reset.Function: return promise-

Customization

You can easily add your own star style via css. You can use the star-width and star-height attributes to make the 'stars' bigger if necessary.

<style>
	.custom.ngrateit .ngrateit-star{
		background-image: url('custom.png');
	}
</style>
<ng-rate-it ng-model="model.custom" class="custom"></ng-rate-it>

Release Note:

V4.0.0

  • BREAKING: The callback function binding has changed form two-way to method binding. This will allow you to pass your own variables to the callback function AND the current rating is passed in the rating parameter:
<ng-rate-it ng-model="model.basic" rated="myCallback(rating, 'Your own var')"></ng-rate-it>
$scope.myCallback = function (rating, cusotmVar) {
	console.log(rating, customVar);
}

To upgrade from v3 to v4, just add () after your function name.

V3.0.0

  • BREAKING: The over callback is removed.
  • BREAKING: If you're using your own template, you need to update it.
  • Template and CSS file are refactored in order to support mobile divices.
  • Moved calculations from template to controller.

FAQs

Package last updated on 13 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc