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

ng-star-rate

v1.0.1

Published

A simple star rating library

Downloads

35

Readme

ng-star-rate

For now, one component is added in this library

<lib-star-rate 
    [selctedColor]="selectColor"
    [star]="item"
    [maxRating]="maxRating"
    [showRatingCounter]="showRatingCounter"
    (ratingSelection)="selectedRating($event)">
</lib-star-rate>

How to use?

  • Include our StarRateModule module in app.module.ts
import { StarRateModule } from 'ng-star-rate';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StarRateModule //<-- add the module in imports
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • Add the component <lib-star-rate> where rating part is expected in your application

To briefly explain what is role of input and output in the components as below

  1. [star] - pass the rating number to the app i.e. - If rating has to be pre-selected. star - hold the default value of rating. | type: number
  2. [maxRating] - pass the maximum rating stars needs to be rendered by that component. | type: number
  3. [showRatingCounter] - this boolean value is to decide whether to show the rating value on the screen like 2 out of 5 | type: boolean
  4. (ratingSelection) - This callback will be triggered when user selects the rating in the component.

Sample implementation

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { StarRateModule } from 'ng-star-rate';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StarRateModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html

<div class="center-align">
  <h1>
    Let's rate it!
  </h1>
    <lib-star-rate
      [selctedColor]="selectColor"
      [star]="item"
      [maxRating]="maxRating"
      [showRatingCounter]="showRatingCounter"
      (ratingSelection)="selectedRating($event)">
    </lib-star-rate>
  <h1 *ngIf="myRating">
    Rated to {{myRating}}
  </h1>
</div>

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {  
  selectColor = 'green';
  item = 0;
  maxRating = 5;
  showRatingCounter = true;
  myRating: number;

  selectedRating(rate: number) {
    console.log('your rating is--', rate);
    this.myRating = rate;
  }
}

Thank you.