我使用bootstrap来显示进度条.要更改进度条中的值,我使用的是Angular 2属性绑定.
<div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" [attr.aria-valuenow]="progress" aria-valuemin="0" aria-valuemax ="100" style="min-width: 2em;" [style.width]="(progress/100)*100 + '%'"> {{progress}}% </div>
当我上传文件时,变量进度将会增加,我可以在控制台日志中看到这些值.
this.service.progress.subscribe( data => { console.log('progress = '+data); this.progress = data; console.log(this.progress) ; });