diff --git a/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.html b/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.html index 98b44f0382..f77f8be06a 100644 --- a/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.html +++ b/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.html @@ -1,10 +1,7 @@ - - - {{baz?.value}}% - - - +
+ +
+
- +
diff --git a/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.ts b/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.ts index 689b5a36b0..89faf296ff 100644 --- a/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.ts +++ b/demo/src/app/components/+progressbar/demos/bs3/stacked/stacked.ts @@ -5,7 +5,6 @@ import { Component } from '@angular/core'; templateUrl: './stacked.html' }) export class DemoProgressbarStackedComponent { - public max: number = 200; public type: string; public stacked: any[] = []; @@ -17,16 +16,14 @@ export class DemoProgressbarStackedComponent { let types = ['success', 'info', 'warning', 'danger']; this.stacked = []; - let total = 0; let n = Math.floor((Math.random() * 4) + 1); for (let i = 0; i < n; i++) { let index = Math.floor((Math.random() * 4)); - let value = Math.floor((Math.random() * 30) + 1); - total += value; + let value = Math.floor((Math.random() * 27) + 3); this.stacked.push({ value, - max: value, // i !== (n - 1) ? value : 100, - type: types[index] + type: types[index], + label: value + ' %' }); } } diff --git a/demo/src/app/components/+progressbar/demos/bs4/dynamic/dynamic.html b/demo/src/app/components/+progressbar/demos/bs4/dynamic/dynamic.html index 8f65b953dc..dd5feec73e 100644 --- a/demo/src/app/components/+progressbar/demos/bs4/dynamic/dynamic.html +++ b/demo/src/app/components/+progressbar/demos/bs4/dynamic/dynamic.html @@ -1,13 +1,13 @@ - + {{dynamic}} / {{max}} - + No animation -{{dynamic}}% +{{dynamic}}% Object (changes type based on value) - + {{type}} !!! Watch out !!! - + diff --git a/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.html b/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.html index 131807d55b..0aa0822faa 100644 --- a/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.html +++ b/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.html @@ -1,16 +1,7 @@
- - - {{baz?.value}}% - - - +
- +
diff --git a/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.ts b/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.ts index d21a5535c1..922dd716fc 100644 --- a/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.ts +++ b/demo/src/app/components/+progressbar/demos/bs4/stacked/stacked.ts @@ -5,7 +5,6 @@ import { Component } from '@angular/core'; templateUrl: './stacked.html' }) export class DemoProgressbarStackedBs4Component { - public max: number = 200; public type: string; public stacked: any[] = []; @@ -17,16 +16,14 @@ export class DemoProgressbarStackedBs4Component { let types = ['success', 'info', 'warning', 'danger']; this.stacked = []; - let total = 0; let n = Math.floor((Math.random() * 4) + 1); for (let i = 0; i < n; i++) { let index = Math.floor((Math.random() * 4)); - let value = Math.floor((Math.random() * 30) + 1); - total += value; + let value = Math.floor((Math.random() * 27) + 3); this.stacked.push({ value, - max: value, // i !== (n - 1) ? value : 100, - type: types[index] + type: types[index], + label: value + ' %' }); } } diff --git a/demo/src/app/components/+progressbar/demos/bs4/static/static.html b/demo/src/app/components/+progressbar/demos/bs4/static/static.html index 64be83f8ff..0bd129fedd 100644 --- a/demo/src/app/components/+progressbar/demos/bs4/static/static.html +++ b/demo/src/app/components/+progressbar/demos/bs4/static/static.html @@ -1,11 +1,11 @@
- +
- 22% + 22%
- 166 / 200 + 166 / 200
diff --git a/demo/src/ng-api-doc.ts b/demo/src/ng-api-doc.ts index 5f979e6902..5822b1200d 100644 --- a/demo/src/ng-api-doc.ts +++ b/demo/src/ng-api-doc.ts @@ -1443,8 +1443,8 @@ export const ngdoc: any = { }, { "name": "value", - "type": "number", - "description": "

current value of progress bar

\n" + "type": "number | any[]", + "description": "

current value of progress bar. Could be a number or array of objects like {"value":15,"type":"info","label":"15 %"}

\n" } ], "outputs": [], diff --git a/src/progressbar/bar.component.ts b/src/progressbar/bar.component.ts index 18d7b7265b..ffb3854b34 100644 --- a/src/progressbar/bar.component.ts +++ b/src/progressbar/bar.component.ts @@ -1,6 +1,7 @@ -import { Component, Host, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, Host, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; import { ProgressDirective } from './progress.directive'; +import { isBs3 } from '../utils/ng2-bootstrap-config'; // todo: number pipe // todo: use query from progress? @@ -10,8 +11,8 @@ import { ProgressDirective } from './progress.directive';
- +
+ +
- ` + `, + styles: [` + :host { + width: 100%; + } + `] }) export class ProgressbarComponent { /** if `true` changing value of progress bar will be animated (note: not supported by Bootstrap 4) */ @@ -18,8 +27,16 @@ export class ProgressbarComponent { @Input() public max:number; /** provide one of the four supported contextual classes: `success`, `info`, `warning`, `danger` */ @Input() public type:string; - /** current value of progress bar */ - @Input() public value:number; + /** current value of progress bar. Could be a number or array of objects like {"value":15,"type":"info","label":"15 %"} */ + @Input() public set value(value: number | any[]) { + this.isStacked = Array.isArray(value); + this._value = value; + }; + public isStacked: boolean = false; + public _value: number | any[]; + public get isBs3(): boolean { + return isBs3(); + } public constructor(config: ProgressbarConfig) { Object.assign(this, config);