Angular1 Star Rating ⭐⭐⭐⭐⭐
⭐ Angular 1.5 Component written in typescript, based on css only techniques. ⭐
Angular1 Star Rating is a >1.5 Angular component written in typescript.
It is based on css-star-rating, a fully featured and customizable css only star rating component written in scss.
DEMO
Related Projects
Css | Angular1 (>=1.5) | Angular (>=2) |
---|---|---|
Css Star Rating | Angular1 Star Rating | Angular Star Rating |
Features
This module implements all Features from CSS-STAR-RATING. It also provides callbacks for all calculation functions used in the component as well as all possible event emitters.
- id - The html id attribute of the star rating
- rating - The actual Star rating
- showHalfStars - To display half stars or not
- showHoverStars - To display hover state on stars or not
- numOfStars - The max number of stars you can rate
- size - The different sizes of the component
- space - The space between stars
- staticColor - A static color for the stars
- disabled - Component is in disabled mode
- starType - Stars can be displayed as svg, character or icon-font like fontawesome, glyphicons or ionicons
- labelText - The value of the label text
- labelHidden - If the label is visible or not
- labelPosition - The position of the label
- speed - The duration of the animation
- direction - The direction of the component i.e. right to left
- readOnly - Click event is disabled
- getColor - Custom function to calculate the color for a rating
- getHalfStarVisible - Custom function to calculate value for displaying half stars or not
- onClick - Event emitter for onClick action
- onRatingChange - Event emitter for onRatingChange event
Browser support
IE | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|
> 11 | > 50 | > 55 | > 10 | > 41 |
Install
*Get Angular1 Star Rating:
- clone & build this repository
- download as .zip
- via npm: by running
$ npm install angular1-star-rating
from your console - via bower: by running
$ bower install angular1-star-rating
from your console - via cdn: by adding the git-cdn reference in your index.html
Load library as minified js file
Inject it into angular
angular
Use it
Component Properties
Input (< bindings)
id: string (Optional)
The html id attribute of the star rating
Default: undefined
rating: number (Optional)
The actual star rating value
Default: 0
showHalfStars: boolean (Optional)
To show half stars or not
Options: true, false
Default: false
showHoverStars: boolean (Optional)
To show hover state on stars or not
Options: true, false
Default: false
numOfStars: number (Optional)
The possible number of stars to choose from
Default: 5
label-text: string (Optional)
The label text next to the stars.
Default: undefined
labelPosition: starRatingPosition (Optional)
The position of the label
Options: top, right, bottom, left
Default: left
space: starRatingStarSpace (Optional)
If the start use the whole space or not.
Options: no, between, around
Default: no
size: starRatingSizes (Optional)
The height and width of the stars.
Options: small, medium, large
Default: ok
color: starRatingColors (Optional)
Possible color names for the stars.
Options: default, negative, ok, positive
Default: undefined
disabled: boolean (Optional)
The click callback is disabled, colors are transparent
Default: false
direction: string (Optional)
The direction of the stars and label.
Options: rtl, ltr
Default: rtl
readOnly: boolean (Optional)
The click callback is disabled
Default: false
speed: starRatingSpeed (Optional)
The duration of the animation in ms.
Options: immediately, noticeable, slow
Default: noticeable
starType: starRatingStarTypes (Optional)
The type of start resource to use.
Options: svg, icon, custom-icon
Default: svg
getColor: Function (Optional)
Calculation of the color by rating.
Params: rating, numOfStars, staticColor
Return: colorName as string
getHalfStarVisible: Function (Optional)
Calculation for adding the "half" class or not, depending on the rating value.
Params: rating
Return: boolean
{ var absDiff = Math; ifabsDiff == 01 return false; return absDiff > 0;}
Output (& bindings)
onClick: Function (Optional)
Callback function for star click event
Params: $event
{ parentclickCount = parentclickCount + 1;}
onRatingChange: Function (Optional)
Callback function for rating update event
Params: $event
{ parentrating = $eventrating;}