Ngx-Bootstrap - ProgressBar
Thành phần thanh tiến trình ngx-bootstrap cung cấp một thành phần tiến trình để hiển thị tiến trình của quy trình làm việc với các thanh linh hoạt.
ProgressbarComponent
bộ chọn
- progressbar 
Đầu vào
- animate - boolean, nếu giá trị thay đổi true của thanh tiến trình sẽ được làm động. 
- max - số, tổng giá trị lớn nhất của phần tử tiến trình. 
- striped - boolean, Nếu đúng, các lớp sọc được áp dụng. 
- type - ProgressbarType, cung cấp một trong bốn lớp ngữ cảnh được hỗ trợ: thành công, thông tin, cảnh báo, nguy hiểm. 
- value- số | bất kỳ [], giá trị hiện tại của thanh tiến trình. Có thể là một số hoặc một mảng các đối tượng như {"value": 15, "type": "info", "label": "15%"}. 
Thí dụ
Vì chúng ta sẽ sử dụng thanh tiến trình, nên chúng ta phải cập nhật app.module.ts được sử dụng trong chương Popover ngx-bootstrap để sử dụngProgressbarModule và ProgressbarConfig.
Cập nhật app.module.ts để sử dụng ProgressbarModule và 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 { }Cập nhật test.component.html để sử dụng phương thức.
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>Cập nhật test.component.ts cho các biến và phương thức tương ứng.
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 {
   } 
}Xây dựng và Phục vụ
Chạy lệnh sau để khởi động máy chủ góc.
ng serveSau khi máy chủ hoạt động. Mở http: // localhost: 4200.