
- Ngx-Bootstrap 教程
- Ngx-Bootstrap - 首頁
- Ngx-Bootstrap - 概述
- Ngx-Bootstrap - 環境設定
- Ngx-Bootstrap - 手風琴
- Ngx-Bootstrap - 警報
- Ngx-Bootstrap - 按鈕
- Ngx-Bootstrap - 走馬燈
- Ngx-Bootstrap - 摺疊
- Ngx-Bootstrap - 日期選擇器
- Ngx-Bootstrap - 下拉選單
- Ngx-Bootstrap - 模態框
- Ngx-Bootstrap - 分頁
- Ngx-Bootstrap - 氣泡提示
- Ngx-Bootstrap - 進度條
- Ngx-Bootstrap - 評分
- Ngx-Bootstrap - 可排序
- Ngx-Bootstrap - 標籤頁
- Ngx-Bootstrap - 時間選擇器
- Ngx-Bootstrap - 工具提示
- Ngx-Bootstrap - 自動完成
- Ngx-Bootstrap 有用資源
- Ngx-Bootstrap - 快速指南
- Ngx-Bootstrap - 有用資源
- Ngx-Bootstrap - 討論
Ngx-Bootstrap - 進度條
ngx-bootstrap 進度條元件提供了一個進度元件,用於顯示工作流的進度,並具有靈活的條形。
ProgressbarComponent
選擇器
progressbar
輸入
animate − 布林值,如果為真,則更改進度條的值將進行動畫處理。
max − 數字,進度元素的最大總值。
striped − 布林值,如果為真,則應用條紋類。
type − ProgressbarType,提供四個支援的上下文類之一:success、info、warning、danger。
value − number | any[],進度條的當前值。可以是數字或物件的陣列,例如 {"value":15,"type":"info","label":"15 %"}。
示例
由於我們將使用進度條,因此我們必須更新在ngx-bootstrap 氣泡提示章節中使用的 app.module.ts 以使用ProgressbarModule 和ProgressbarConfig。
更新 app.module.ts 以使用 ProgressbarModule 和 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 { }
更新 test.component.html 以使用模態框。
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>
更新 test.component.ts 以對應變數和方法。
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 { } }
構建和服務
執行以下命令啟動 Angular 伺服器。
ng serve
伺服器啟動並執行後。開啟 https://:4200。
廣告