Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
ng-voting
is a reusable Angular component that can be used to easily implement a voting platform in your app. It is responsive and completely customizable.
npm i ng-voting
NgVotingComponent
in the module of your choice....
import { NgVotingComponent } from 'ng-voting'
@NgModule({
declarations: [
AppComponent
],
imports: [
...,
NgVotingComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
your.component.ts
add some data of type Voting
. can be import like import { Voting } from ng-voting
your.component.html
add the ng-voting
tag and pass you data of type Voting
to [data]
as shown below.your.component.ts
import { Voting } from 'ng-voting';
@Component({
selector: 'your-root',
templateUrl: './your.component.html'
})
export class YourComponent {
data: Voting = {
question: "Do you like ng-voting?",
options: [
{
label: "Yes",
value: "yes",
votesCount: 1,
imageUrl: "optional-image-url",
users: [
...users,
{
name: "John Snow",
image: "assets/profile1.jpg"
},
]
},
{
label: "No",
value: "no",
votesCount: 0,
imageUrl: "optional-image-url"
}
]
}
optionSelected(value: string) {
// You get back the selected option here.
}
your.component.html
<ng-voting
[data]="data" (selected)="optionSelected($event)"></ng-voting>
Voting
export interface Voting {
question: string,
options: Option[]
}
export interface Option {
label: string,
value: string,
votesCount: number,
imageUrl?: string,
users?: {name: string, image?: string}[],
color?: string,
selected?: boolean,
}
StyleParams
like import { StypeParams } from 'ng-voting'
, and create and object.[styleParams]
in your html. (use rem
instead of px
)// In your .ts file, create an object and change these values
// (use `rem` and not `px`)
styleParams: StyleParams = {
borderColor: '#d3d3d3',
margin: '1rem',
hoverColor: '#ebebeb',
scaleColor: '#9797dc',
fontSize: '1.5rem',
topicBackgroundColor: '#ffffff',
optionsBackgroundColor: '#ffffff',
topicFontColor: 'black',
optionsFontColor: 'black'
}
// In your html file, pass that object.
<ng-voting
[data]="data"
[styleParams]="styleParams"
(selected)="increaseVoteCount($event)"></ng-voting>
API | Type | Description | Default | Required |
---|---|---|---|---|
[data] | Voting | Voting topic and option and their details | undefined | true |
[isLoading] | boolean | Show loading state | false | false |
[showUsers] | boolean | Show the users count on option | true | false |
[showScale] | boolean | Show the percentage scale of voting | true | false |
[disable] | boolean | Disable voting | false | false |
[selectedOptionValue] | boolean | Shows a checkmark of which option was selected by user | "" | false |
[styleParams] | StyleParams | Customize the Voting component. | borderColor: '#d3d3d3', margin: '1rem', hoverColor: '#ebebeb', scaleColor: '#9797dc', fontSize: '1.5rem', topicBackgroundColor:'#ffffff', optionsBackgroundColor:'#ffffff', topicFontColor: 'black', optionsFontColor: 'black' | false |
(selected) | string | Emits the selected option value |
<ng-voting
[data]="data"
[styleParams]="styleParams"
[showScale]="true"
[showUsers]="true"
[isLoading]="false"
[selectedOptionValue]="''"
[disable]="false"
(selected)="handleVote($event)"></ng-voting>
FAQs
A reusable and customizable voting component for Angular projects
The npm package ng-voting receives a total of 3 weekly downloads. As such, ng-voting popularity was classified as not popular.
We found that ng-voting demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.