The documentation on bootstrap progress bars illustrate how to display a progress bar with default values and completion value, but now how to update it? So, what's the simplest way to go about updating the value and width?
This is my progress bar in file home.html:
<div class="progress">
<div id="trainingProgressBar" class="progress-bar
progress-bar-success progress-bar-striped active"
role="progressbar"
aria-valuenow="40" aria-valuemin="0"
aria-valuemax="100" style="width:40%">
{{trainingProgress}}% Complete
</div>
</div>
and in my home.ts file I declare my trainingProgress value:
public trainingProgress: number = 10;
The text will change to whatever trainingProgress is, but the width will not because trainingProgress isn't linked to aria-valuenow
and width:%
.
Documentation and examples for using Bootstrap custom progress bars featuring support for stacked bars, animated backgrounds, and text labels. Progress components are built with two HTML elements, some CSS to set the width, and a few attributes.
To create a default progress bar, add a .progress class to a container element and add the .progress-bar class to its child element. Use the CSS width property to set the width of the progress bar:
We use the .progress as a wrapper to indicate the max value of the progress bar. We use the inner .progress-bar to indicate the progress so far. The .progress-bar requires an inline style, utility class, or custom CSS to set their width. The .progress-bar also requires some role and aria attributes to make it accessible.
Include multiple progress bars in a progress component if you need. Add .progress-bar-striped to any .progress-bar to apply a stripe via CSS gradient over the progress bar’s background color. The striped gradient can also be animated. Add .progress-bar-animated to .progress-bar to animate the stripes right to left via CSS3 animations.
Use attribute and style binding:
<div class="progress">
<div id="trainingProgressBar" class="progress-bar
progress-bar-success progress-bar-striped active"
role="progressbar"
aria-valuemin="0"
aria-valuemax="100"
[attr.aria-valuenow]="trainingProgress"
[style.width.%]="trainingProgress">
{{trainingProgress}}% Complete
</div>
</div>
Here the PLUNKER
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With