Progress Bar in ionic2

Is there any standard or plugins to show the progress bar in ionic2? like a progress bar shows how many percent of downloading progress.

Thanks

2 Likes

Hey man. I havent found any standard and I tried using the HTML5 progress element to no avail. This is a bit late, but hopefully it helps.

I hadn’t seen anything to suggest that they were working on it, so I started one on my own that you could use to start yourself off.

I started with an HTML5 progress bar native element, but had trouble styling it. For some reason the hidden elements that it creates (-webkit-progress-value…) would not style. So I feel back to following this guide.

I came up with this progress bar for myself. The code looks a bit like this.

    <div class="progress-bar">
      <span [style.width]="workoutProgress">{{workoutProgress}}</span>
    </div>   

with a component that looks like,

  public workoutProgress: string = '0' + '%';
 
updateProgress(val) {
 // Update percentage value where the above is a decimal
  this.workoutProgress = Math.min( (val * 100), 100) + '%';
}

Hope this helps. The style guide I use is,

    .progress-bar {
    background-color: color($colors, description);
    height: 20px;
    width: 80%;
    padding-top: 2px;
    padding-bottom: 1px;
    padding-left: 2px;
    padding-right: 2px;
    margin-left: 10%;
    margin-right: 10%;
    margin-top: 10px;
    margin-bottom: 10px;
    box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
    border-radius: 5px;

    span {
        text-align: center;
        display: inline-block;
        height: 100%;
        border-radius: 3px;
        box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
        background-color: color($colors, primary);
        transition: width .4s ease-in-out;    
    }
}
6 Likes

Oh, it’s great. I am not working on it any more, but I will send this code to my colleague. Thank you so much @thielcole

Thank you ! I will use it in my project

Does this still work? I am getting - inline template:7:2 caused by: Failed to execute 'setAttribute' on 'Element': ']' is not a valid attribute name. on trying to set width programmatically. Anyone knows any other way?

Nevermind. simple error in my code. Thanks

thanks, it help me a lot.