Ngx-Bootstrap - ProgressBar
O componente da barra de progresso do ngx-bootstrap fornece um componente de progresso para mostrar o progresso de um fluxo de trabalho com barras flexíveis.
ProgressbarComponent
seletor
progressbar
Entradas
animate - booleano, se o valor de mudança verdadeiro da barra de progresso será animado.
max - número, valor total máximo do elemento de progresso.
striped - booleano, se verdadeiro, classes distribuídas são aplicadas.
type - ProgressbarType, fornece uma das quatro classes contextuais com suporte: sucesso, informação, aviso, perigo.
value- número | qualquer [], valor atual da barra de progresso. Pode ser um número ou matriz de objetos como {"value": 15, "type": "info", "label": "15%"}.
Exemplo
Como vamos usar uma barra de progresso, precisamos atualizar app.module.ts usado no capítulo ngx-bootstrap Popover para usarProgressbarModule e ProgressbarConfig.
Atualize app.module.ts para usar ProgressbarModule e 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 { }
Atualize test.component.html para usar o modal.
test.component.html
<div class="row">
<div class="col-sm-4">
<div class="mb-2">
<progressbar [value]="value"></progressbar>
</div>
</div>
<div class="col-sm-4">
<div class="mb-2">
<progressbar [value]="value" type="warning"
[striped]="true">{{value}}%</progressbar>
</div>
</div>
<div class="col-sm-4">
<div class="mb-2">
<progressbar [value]="value" type="danger"
[striped]="true" [animate]="true"
><i>{{value}} / {{max}}</i></progressbar>
</div>
</div>
</div>
Atualize test.component.ts para variáveis e métodos correspondentes.
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 {
}
}
Construir e servir
Execute o seguinte comando para iniciar o servidor angular.
ng serve
Assim que o servidor estiver instalado e funcionando. Abra http: // localhost: 4200.