ng2-bootstrap-base-modified
Version:
Native Angular Bootstrap Components Typeahead modified
43 lines (33 loc) • 1.12 kB
text/typescript
import { Directive, HostBinding, Input } from '@angular/core';
import { BarComponent } from './bar.component';
// todo: progress element conflict with bootstrap.css
// todo: need hack: replace host element with div
({selector: 'bs-progress, [progress]'})
export class ProgressDirective {
/** if `true` changing value of progress bar will be animated (note: not supported by Bootstrap 4) */
() public animate:boolean;
/** maximum total value of progress element */
('attr.max')
()
public get max():number {
return this._max;
}
public set max(v:number) {
this._max = v;
this.bars.forEach((bar:BarComponent) => {
bar.recalculatePercentage();
});
}
('class.progress') public addClass:boolean = true;
public bars:any[] = [];
protected _max:number = 100;
public addBar(bar:BarComponent):void {
if (!this.animate) {
bar.transition = 'none';
}
this.bars.push(bar);
}
public removeBar(bar:BarComponent):void {
this.bars.splice(this.bars.indexOf(bar), 1);
}
}