Star ⭐ rating system in angular 12 example. In this tutorial, i will teach you step by step how to build star ⭐ rating component in Angular 12 version and Bootstrap.
The star ⭐ rating system is often used to measure the quality of a particular product or service.
Star ⭐ Rating in Angular 12 Example
- Step 1 – Create New Angular App
- Step 2 – Install Marked Parser Package
- Step 3 – Install NGBootstrap in Angular
- Step 4 – Add Code on View File
- Step 5 – Add Code On app.Component ts File
- Step 6 – Start the Angular Star Rating App
Step 1 – Create New Angular App
Execute the following command on terminal to install angular app:
ng new my-new-app
Step 2 – Install Marked Parser Package
Then Install the marked Markdown parser plugin through NPM. Its a low-level and powerful compiler for parsing Markdown without caching or blocking for long periods. So, You can install the packages by executing the following commands on the terminal:
npm i marked
Step 3 – Install NGBootstrap in Angular
Execute the following command on terminal to install the ng-bootstrap package:
ng add @ng-bootstrap/ng-bootstrap
Step 4 – Add Code on View File
Create star ⭐ rating in angular app. So, visit src/app/ and app.component.htmland update the following code into it:
<h2>Angular 12 Star Rating Example</h2> <ngb-rating [max]="5" [(rate)]="starRating" [readonly]="false"></ngb-rating>
Step 5 – Add Code On app.Component ts File
Go to src/app directory and open app.component.ts. Then add the following code into component.ts file:
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { starRating = 0; }
Step 6 – Start the Angular Star Rating App
Execute the following command on terminal to start angular star rating app:
ng serve