Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patrickvaler/ng-vote
🚀 Simple & lightweight Angular 2/4 vote component
https://github.com/patrickvaler/ng-vote
angular angular2 typescript vote voter
Last synced: 16 days ago
JSON representation
🚀 Simple & lightweight Angular 2/4 vote component
- Host: GitHub
- URL: https://github.com/patrickvaler/ng-vote
- Owner: patrickvaler
- Created: 2017-05-20T00:18:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T12:22:56.000Z (about 6 years ago)
- Last Synced: 2024-10-10T06:43:46.126Z (28 days ago)
- Topics: angular, angular2, typescript, vote, voter
- Language: TypeScript
- Homepage: https://plnkr.co/edit/Gz4LszNzdUfWYe1bLoGA?p=preview
- Size: 143 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/ng-vote.svg)](http://badge.fury.io/js/ng-vote) [![Build Status](https://travis-ci.org/patrickvaler/ng-vote.svg?branch=master)](https://travis-ci.org/patrickvaler/ng-vote) [![Dependency Status](https://david-dm.org/patrickvaler/ng-vote/status.svg?style=flat)](https://david-dm.org/patrickvaler/ng-vote)
ng-vote
=======Simple & lightweight Angular 2/4 voting component. Demo is available on [Plunker][plunkerDemo].
![ng-vote demo][demo]
## Installation
To install ng-vote, run:
```bash
$ npm install ng-vote --save
```## Usage
Import `NgVoteModule` into your Angular application:```typescript
// Import ng-vote
import { NgVoteModule } from 'ng-vote';@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Specify ng-vote as an import
NgVoteModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```Once ng-vote is imported, you can use it in your Angular application:
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
voteConfig: {
cssClass: 'my-class',
allowEdit: true,
disabled: false
}
votes: 123, // total amount of votes
selectedVote: 0 // not voted yetonVote(vote) {
console.log('onVote response: ', vote)
}
}
``````html
Up
Down
Up
Down```
## Bindings
### ng-vote
#### @Input* **[totalVotes]**: number `Default: 0`
* **[selectedVote]**: number `Default: 0`
_One of -1 (downVote), 0 (not voted), 1 (upVote)_
* **[config]**: Object
* **allowEdit**: boolean `Default: true`
_Defines if user is allowed to change his the selection._
* **disabled**: boolean `Default: false`
_Disables vote functionality._
* **cssClass**: string `Default: ''`
_Sets custom css class to override styles._
#### @Output
* **(vote)**: Object
* **selectedVote**: number
* **totalVotes**: number### ng-vote-up / ng-vote-down
No bindings available for `` / ``. Content will be projected to the ``.## Demo
Demo of the Angular 2/4 voting component is available on [Plunker][plunkerDemo].## License
*The MIT License (MIT)*
Copyright (c) 2017 Patrick Valer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---
Made with ♥ by [Patrick Valer][patrickvalerCh] ()[patrickvalerCh]: https://www.patrickvaler.ch "patrickvaler.ch"
[plunkerDemo]: https://plnkr.co/edit/Gz4LszNzdUfWYe1bLoGA?p=preview "ng-vote demo on Plunker"
[demo]: https://image.ibb.co/niY4kv/ng_vote_demo.gif "ng-vote demo"