- Ngx-Bootstrap - Discussion
- Ngx-Bootstrap - Useful Resources
- Ngx-Bootstrap - Quick Guide
- Ngx-Bootstrap - Typeahead
- Ngx-Bootstrap - Tooltip
- Ngx-Bootstrap - Timepicker
- Ngx-Bootstrap - Tabs
- Ngx-Bootstrap - Sortable
- Ngx-Bootstrap - Rating
- Ngx-Bootstrap - Progressbar
- Ngx-Bootstrap - Popover
- Ngx-Bootstrap - Pagination
- Ngx-Bootstrap - Modals
- Ngx-Bootstrap - Dropdowns
- Ngx-Bootstrap - DatePicker
- Ngx-Bootstrap - Collapse
- Ngx-Bootstrap - Carousel
- Ngx-Bootstrap - Buttons
- Ngx-Bootstrap - Alerts
- Ngx-Bootstrap - Accordion
- Ngx-Bootstrap - Environment Setup
- Ngx-Bootstrap - Overview
- Ngx-Bootstrap - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Ngx-Bootstrap - ProgressBar
ngx-bootstrap progress bar component provides a progress component to show progress of a workflow with flexible bars.
ProgressbarComponent
selector
progressbar
Inputs
animate − boolean, if true changing value of progress bar will be animated.
max − number, maximum total value of progress element.
striped − boolean, If true, striped classes are appped.
type − ProgressbarType, provide one of the four supported contextual classes: success, info, warning, danger.
value − number | any[], current value of progress bar. Could be a number or array of objects pke {"value":15,"type":"info","label":"15 %"}.
Example
As we re going to use a progressbar, We ve to update app.module.ts used in
chapter to use ProgressbarModule and ProgressbarConfig.Update app.module.ts to use the ProgressbarModule and ProgressbarConfig.
app.module.ts
import { BrowserModule } from @angular/platform-browser ; import { NgModule } from @angular/core ; import { BrowserAnimationsModule } from @angular/platform-browser/animations ; import { AppComponent } from ./app.component ; import { TestComponent } from ./test/test.component ; import { AccordionModule } from ngx-bootstrap/accordion ; import { AlertModule,AlertConfig } from ngx-bootstrap/alert ; import { ButtonsModule } from ngx-bootstrap/buttons ; import { FormsModule } from @angular/forms ; import { CarouselModule } from ngx-bootstrap/carousel ; import { CollapseModule } from ngx-bootstrap/collapse ; import { BsDatepickerModule, BsDatepickerConfig } from ngx-bootstrap/datepicker ; import { BsDropdownModule,BsDropdownConfig } from ngx-bootstrap/dropdown ; import { PaginationModule,PaginationConfig } from ngx-bootstrap/pagination ; import { PopoverModule, PopoverConfig } from ngx-bootstrap/popover ; import { ProgressbarModule,ProgressbarConfig } from ngx-bootstrap/progressbar ; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot(), BsDropdownModule, ModalModule, PaginationModule, PopoverModule, ProgressbarModule ], providers: [AlertConfig, BsDatepickerConfig, BsDropdownConfig, BsModalService, PaginationConfig, ProgressbarConfig], bootstrap: [AppComponent] }) export class AppModule { }
Update test.component.html to use the modal.
test.component.html
<span class="row"> <span class="col-sm-4"> <span class="mb-2"> <progressbar [value]="value"></progressbar> </span> </span> <span class="col-sm-4"> <span class="mb-2"> <progressbar [value]="value" type="warning" [striped]="true">{{value}}%</progressbar> </span> </span> <span class="col-sm-4"> <span class="mb-2"> <progressbar [value]="value" type="danger" [striped]="true" [animate]="true" ><i>{{value}} / {{max}}</i></progressbar> </span> </span> </span>
Update test.component.ts for corresponding variables and methods.
test.component.ts
import { Component, OnInit } from @angular/core ; @Component({ selector: app-test , templateUrl: ./test.component.html , styleUrls: [ ./test.component.css ] }) export class TestComponent implements OnInit { max: number = 100; value: number = 25; constructor() {} ngOnInit(): void { } }
Build and Serve
Run the following command to start the angular server.
ng serve
Once server is up and running. Open http://localhost:4200.
Advertisements