
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
ngx-simple-progress-bar
Advanced tools
Angular 'ngx-simple-progress-bar' is an easy-to-use, customizable component, which can show both dynamic loading and static progress.
Angular 'ngx-simple-progress-bar' is an easy-to-use, customizable component, which can show both dynamic loading and static progress.
NPM package: https://www.npmjs.com/package/ngx-simple-progress-bar
The library's major version is the same as the Angular version it requires, that is, e.g. 12.0.0 is for Angular 12 (and upwards). Lowest available version is 9.0.0.
npm install ngx-simple-progress-bar --save
An example app is available here
Install the library via npm
If you use NgModules, import NgxSimpleProgressBarModule
into your AppModule:
```
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxSimpleProgressBarModule } from 'ngx-simple-progress-bar';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxSimpleProgressBarModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
```
Use <ngx-simple-progress-bar>
in your component's template and customize it as you prefer:
```
<div class="container">
<ngx-simple-progress-bar [percent]="percent"
[color]="color"
[backgroundColor]="backgroundColor"
[height]="height"
[progressBarType]="progressBarType"
[isStatic]="false"
(percentChange)="onPercentChange($event)">
</ngx-simple-progress-bar>
</div>
```
Don't forget to set the width of the container div as the full length of the progress bar fits its container.
From version 17.0.0 upwards (compatible with Angular 17), the progress bar is also available as a standalone component.
Use<ngx-simple-progress-bar-standalone>
in your component's template and customize it exactly the same way as the non-standalone component:
```
<div class="container">
<ngx-simple-progress-bar-standalone [percent]="percent"
[color]="color"
[backgroundColor]="backgroundColor"
[height]="height"
[progressBarType]="progressBarType"
[isStatic]="false"
(percentChange)="onPercentChange($event)">
</ngx-simple-progress-bar-standalone>
</div>
```
You can inject NgxSimpleProgressBarService
into your component and use its methods for dynamic loading
functionality:
```
import { Component, OnInit } from '@angular/core';
import { NgxSimpleProgressBarService } from 'ngx-simple-progress-bar';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
percent: number;
speed: number;
constructor(private readonly progressBarService: NgxSimpleProgressBarService) {
}
ngOnInit(): void {
this.percent = 50;
this.speed = 100;
}
start(): void {
this.progressBarService.startProgress(this.percent, this.speed);
}
stop(): void {
this.progressBarService.stopProgress();
}
reset(): void {
this.progressBarService.resetProgress();
}
complete(): void {
this.progressBarService.completeProgress();
}
onPercentChange(changedPercent: number): void {
this.percent = changedPercent;
}
}
```
When the above service methods are used, NgxSimpleProgressBarComponent
's percentChange
event is emitted to give
feedback to the host component about the updated value of the percent.
You can set the following properties of the progress bar:
percent: by default 0, it shows the current state of progress by setting the inner bar's width
isStatic: by default true
, its value describes whether the service's methods are blocked; set it to false
to allow
the service methods to change the percent dynamically
progressBarType: there are 3 types of progress bar designs available:
color: the background color of the inner bar, default: #4d94f7
backgroundColor: the background color of the outer bar, default: #efefef; with rounded/square designs you can set it to transparent in order to hide the full length of the progress bar
height: the outer bar's height (defaults: 22px for classic, 12px for rounded, 5px for square)
NgxSimpleProgressBarService
internally uses interval
from rxjs
: when we launch the progress, we can set the
initial percent from which to start out as well as the 'speed', that is, the number of milliseconds at which
rate interval
emits its next number and our percent is increased by 1. Default percent is 0; default speed is 50
milliseconds. Thus, the method startProgress() can have 0, 1 or 2 parameters:
startProgress()
/ startProgress(percent)
/ startProgress(percent, speed)
The method stopProgress()
stops the progress and the last percent value is preserved.
The method resetProgress()
sets the percent to 0; if not stopped, the increase of percents resumes.
The method completeProgress()
speeds up the progress (1 percent increase every 5 milliseconds) and the progress stops
at 100%.
FAQs
Angular 'ngx-simple-progress-bar' is an easy-to-use, customizable component, which can show both dynamic loading and static progress.
The npm package ngx-simple-progress-bar receives a total of 11 weekly downloads. As such, ngx-simple-progress-bar popularity was classified as not popular.
We found that ngx-simple-progress-bar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.