npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-rateit

v4.0.3

Published

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.

Downloads

65

Readme

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

| 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 | | read-only | Whether or not is readonly. | Boolean | false | | pristine | Whether or not the current value is the initial value. | Boolean | true | | resetable | When not readonly, whether to show the reset button. | Boolean | true | | star-width | Width of the star picture. | Integer | 16 | | star-height | Height of the star picture. | Integer | 16 | | cancel-width | Width of the cancel icon. | Integer | star-width | | cancel-height | Height of the cancel icon. | Integer | star-height | | rated | Fired when a rating happened. (Obtain the rated value by the model) | Function | - | | reset | Fired when the reset button was clicked. | Function | - | | before-rated | Fired before the item is actually rated. By rejecting the promise it is possible to cancel the rating. | Function: return promise | - | | before-reset | Fired 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.