Angular2の進捗バーにデータをバインドする方法はありますか? a {{}}はaria-valuenowのような既存の属性や進捗タグの値には作用しません。以下はブートストラップ1です。詳細進捗バーへのバインド
update.service.tsと
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100" style="width:70%">
<span class="sr-only">70% Complete</span>
</div>
</div>
更新:プログレスバーを表示するコンポーネント:これはobseverable、
public _progress$: Observable<number>;
private _progress: number = 0;
private _progressObserver: Observer<number>;
constructor(private _http:Http, private _configurationService: ConfigurationService,private _authenservice:AuthenticationService) {
this._progress$ = new Observable(observer => {
this._progressObserver = observer
});
}
....
this._progressObserver.next(this._progress); // this is to push in the progress number from xhr.upload.onprogress
home.component.tsを作成することです、
private _uploadProgressStatus:Observable<number>;// as "asyn" only takes in the promise of observable, I plan to feed _uploadProgressStatus in
constructor(private _videoManagementService:VideoManagementService,
private _uploadService:UploadService) {
console.info('HomeComponent Mounted Successfully');
this._uploadProgressStatus = this._uploadService._progress$;
this._uploadProgressStatus.subscribe(
data => {
console.log('progress = '+data/100);
}); //if subscribe to this._uploadProgressStatus, no values are received...
this._uploadService._progress$.subscribe(
data => {
console.log('progress = '+data/100);
});
} // if subscribe to this._uploadService._progress$ ,numbers are received.
home.component.html
<h4>Uploading...{{ _uploadProgressStatus | async | percent}}</h4>
<div class="progress">
<div class="progress-bar" role="progressbar" [style.width]="_uploadProgressStatus | async | percent" aria-valuemin="0" aria-valuemax="100">
<h4>{{ _uploadProgressStatus | async | percent}} </h4>
</div>
</div>
これは機能しません。ですから、問題は、home.component.tsにobservableを作成して数値を受け取る方法です。 _uploadService._progress $へのhtml更新_uploadProgressStatusで
もそれは非常にシンプルであるべき
開始............................... function myStartFunction() { myVar = setInterval(myTimer、200); } –
ありがとうございます。はい、設定間隔は間違いなく機能します。私はAngular2で何か方法があるかどうかをもっと見ています – Hammer
(a> = 99){myStopFunction(); ....とあなたの関数...} –