Code Monkey home page Code Monkey logo

angular-input-stars's Introduction

Welcome

With this directive you can build rating inputs easily.

Look! A demo!

Installation via bower

bower install angular-input-stars

Inject it

angular.module('app', ['angular-input-stars'])

Use

Simple usage

<input-stars max="5" ng-model="YourCtrl.property"></input-stars>

Customize the base, empty, hover, half and full and icon classes via attributes

<input-stars
    max="5"
    allow-half
    icon-base="fa fa-fw"
    icon-empty="fa-star-o"
    icon-half="fa-star-half-o"
    icon-full="fa-star" 
    icon-hover-full="fa-star" 
    ng-model="YourCtrl.property"
    ></input-stars>

Unlike icon-base, on icon-full, icon-hover and icon-empty you must specify only one class, but that is all you need : ]

Customize or initalize the directive attributes using the ng-attr-{attr} directive thanks to timkishkin for pointing the need of a better clarification

<input-stars 
    ng-model="App.prop1" 
    max="5"
    ng-attr-readonly="{{ enableReadonly || false }}" 
    ng-attr-icon-empty="{{ enableReadonly ? 'fa-twitter' : 'fa-circle-o' }}"
    ng-attr-icon-full="{{ enableReadonly ? 'fa-cog' : 'fa-twitter' }}"
></input-stars> value: {{App.prop1}}

Add a $rootScope function that will be called each time after a star is clicked by using the optional onStarClick attribute (thanks to @whitef0x0)

<input-stars max="5" on-star-click="runMyFunction()" ng-model="YourCtrl.property"></input-stars>

Customize the list class to whatever you want

<input-stars max="5" list-class="shiny-list" ng-model="YourCtrl.property"></input-stars>

Make it readonly, thanks to @anjorinjnr

<input-stars max="10" list-class="shiny-list" ng-model="YourCtrl.property" readonly ></input-stars>
<input-stars max="10" list-class="shiny-list" ng-model="YourCtrl.property" readonly="true" ></input-stars>
<input-stars max="10" list-class="shiny-list" ng-model="YourCtrl.property" readonly="readonly" ></input-stars>

Allow it to have half-icon painted, thanks to @brunoksato

<input-stars max="10" list-class="shiny-list" ng-model="YourCtrl.property" allow-half ></input-stars>

The .css file is optional and it is a bootstrap for customizations.

##Dependencies This directive uses FontAwesome as fallback if you don't specify any icon class.

License

MIT License © Rafael Mello Campanari

angular-input-stars's People

Contributors

akholodenko avatar anjorinjnr avatar brunoksato avatar machmet avatar martinomensio avatar melloc01 avatar miguepiscy avatar pauloluan avatar whitef0x0 avatar

Watchers

 avatar  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.