Angular progress tracker with stages

I have been exploring ways to create a progress bar with steps in Angular 12 that advances based on the percentage of progress rather than just moving directly from one step to another. This is specifically for displaying membership levels and indicating how much progress is needed to reach the next level. I came across an example in React called CustomStepper, which can be found here. Does anyone know of a similar example or solution for Angular 12? Any help would be greatly appreciated!

https://i.sstatic.net/SYeR5.png

Answer №1

Have you considered utilizing the Angular Stepper for your project requirements? With a bit of tweaking, it could be the perfect solution for what you need.

Take a look at this interactive demo that demonstrates how to progress through a stepper based on a percentage without automatically moving to the next step. You can also see how to advance to the next level with a simple button click. Feel free to adjust and customize it to fit your specific needs!

I trust this information will prove useful to you in achieving your desired outcome.

Answer №2

A progress bar utilizes a basic percentage value ranging from 0 to 100 to determine the fill level of the bar. You can find more information about progress bars at this link.

To calculate and pass this percentage to <mat-progress-bar>, create a method as shown below:

<mat-progress-bar mode="determinate" [value]="percent"></mat-progress-bar>
<br />
<br />
<button (click)="onStep(1)">next step</button>
<button (click)="onStep(-1)">previous step</button>
/**
 * @title Determinate progress-bar
 */
@Component({
  selector: 'progress-bar-determinate-example',
  templateUrl: 'progress-bar-determinate-example.html',
})
export class ProgressBarDeterminateExample {
  percent: number = 50;
  maxSteps: number = 20;
  currentStep: number = 10;

  onStep(step: number) {
    this.currentStep += step;
    if (this.currentStep > this.maxSteps) {
      this.currentStep = this.maxSteps;
    } else if (this.currentStep < 0) {
      this.currentStep = 0;
    }

    this.percent = (this.currentStep * 100) / this.maxSteps;
    console.log(step);
    console.log(this.percent);
  }
}

For a live demonstration, refer to this working example: Link to StackBlitz

Answer №3

My preferred choice is the one offered by Angular Material. For more information, you can visit this link.

When working with Angular and needing to make dynamic changes to HTML, utilizing property binding is recommended. By binding the value property, TypeScript can provide updates as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to retrieve files from public folder on express server using a React application

The Issue When trying to render images saved on the backend using Express, I am facing a problem where the images appear broken in the browser. Despite looking for solutions to similar issues, none have resolved the issue for me. Specifics In my server.t ...

Is it possible to automatically set focus on the input box in an html tag multiple times instead of just once with autofocus?

Currently, I am developing an online editor that allows users to quickly edit individual words. My approach involves replacing specific words with input boxes containing the word for direct editing by users. In order to streamline the process and ensure e ...

What are the best ways to make the most of Angular Material density?

Material has introduced a new density component modifier (Check out the links here and here). After importing material/density, I followed the recommended code structure in my scss file: @use "@material/button"; .my-custom-button { // Adjusts ...

Organizing a vast TypeScript project: Comparing Modules and Namespaces

As someone relatively new to TypeScript, I am currently working on a small prototyping framework for WebGl. During my project refactoring, I encountered challenges in organizing my code, debating between using modules or namespaces as both have their drawb ...

Utilizing the Pub/Sub architecture to integrate the kafka-node library within Node Js

Utilizing the kafka-node module in my NodeJs Microservise project, I am aiming to implement a Pub/Sub (publisher and subscriber) design pattern within the Functional programming paradigm. producer.js const client = new kafka.KafkaClient({ kafkaHost: ...

Issue with PrimeNG overlaypanel displaying error message "Functionality of this.engine.setProperty is not available"

After importing OverlayPanelModule as @NgModule in parent.module.ts, I added the following code in child.component.html: <p-overlayPanel [dismissable]="false" #overlay> Content </p-overlayPanel> However, upon testing, I encountered the error ...

Resolving the Issue: How to Solve the "Missing Required Request Body" Error in Angular and Spring MVC

I'm encountering an issue with removing a product from the database using Angular on the frontend. The error message I am receiving is: Required request body is missing: public boolean prodcust.controller.DeleteController.deleteProduct(java.lang.Stri ...

Are there more efficient methods for locating a particular item within an array based on its name?

While I know that using a loop can achieve this functionality, I am curious if there is a built-in function that can provide the same outcome as my code below: const openExerciseListModal = (index:number) =>{ let selectedValue = selectedItems[index]; it ...

Angular 7 and Express: No content returned in response body after making a POST request

I am encountering an issue with retrieving the response from a POST request in Angular 7. When I set the API to return "text," everything works as expected. However, when I change the response to JSON, the response body in Angular appears to be null. Test ...

CLI package enables exporting API facilities

I have a mono repository containing a CLI package (packages/cli) and a web application (apps/web). I want to utilize the public API of the CLI within the web app. The CLI package is packaged with tsup: export default defineConfig({ clean: false, dts: ...

The Angular template-driven form featuring Material inputs will automatically reset itself when initialized

I am currently working on a simple template-based form in my application, utilizing material form fields. I have opted for this approach instead of a reactive one. The desired functionality is to display the form only when the user clicks on a button. Up ...

Is it possible to integrate ngx Pagination with Bootstrap?

Is it possible to integrate Bootstrap's pagination with ngx Pagination? I'm interested in using the functionality of ngx Pagination but styling it with the CSS from Bootstrap. ...

Zero's JSON Journey

When I make an HTTP request to a JSON server and store the value in a variable, using console.log() displays all the information from the JSON. However, when I try to use interpolation to display this information in the template, it throws the following er ...

Is there a way to initiate validations for inputs within ReactiveForms?

After creating a form using Reactive Forms, I have implemented functionality for users to set a new password. The process involves entering both the old and new passwords, as well as confirming the new password. Throughout development, I considered the fol ...

`What exactly do auth.guard.ts and the AuthenticationService do in Angular 8?`

import { Injectable } from '@angular/core'; import { AuthenticationService } from './_services'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; @Injectable({ providedIn: & ...

The Angular TypeScript service encounters an undefined issue

Here is an example of my Angular TypeScript Interceptor: export module httpMock_interceptor { export class Interceptor { static $inject: string[] = ['$q']; constructor(public $q: ng.IQService) {} public request(config: any) ...

Error: NativeScript has encountered difficulty locating the module "@nativescript/schematics"

While attempting to generate a component called "movies" with the command tns generate component movies, I encountered the following error in the terminal log: Could not find module "@nativescript/schematics". I followed the suggestions provided in this G ...

Is "as" truly necessary in this context?

After following a tutorial, I created a class and noticed that the interface was declared with an as name. I'm wondering if this is necessary. What is the purpose of reassigning it when it was already assigned? My TypeScript code: import { Component ...

Despite the unconsumedBufferLength being 0, DataReader.loadAsync is still being completed

Working on UWP WinRT, I'm dealing with JSON stream consumption using the following code: async function connect() { let stream: MSStream; return new CancellableContext<void>( async (context) => { stream ...

What is the method for passing an element in Angular2 Typescript binding?

Is there a way to retrieve the specific HTML dom element passed through a binding in Angular? I'm having trouble figuring it out, so here is the relevant code snippet: donut-chart.html <div class="donut-chart" (donut)="$element"> ...