2
A
回答
1
您可以或者refer this to do it sanely with angular2 HTTP模块。
否则同样可以用XHR progress
事件jQuery中进行:
import { Subject } from 'rxjs/Subject';
export class ProgressLoader {
percentage$: Subject<any>;
constructor() {
this.percentage$ = new Subject();
$.ajax({
type: 'GET',
url: 'http://google.com',
xhr: function() {
var xhr = new window.XMLHttpRequest(),
xhr.addEventListener("progress", (evt) => {
this.percentage$.next(parseInt(evt.loaded/evt.total * 100, false) + '%');
}, false);
return xhr;
}
});
}
}
相关问题
- 1. 角度,如何停止跟踪服务对象
- 2. CAAnimation跟踪进度
- 3. 使用Parallel.ForEach跟踪进度
- 4. 角度如何跟踪绑定?
- 5. 跟踪多步骤任务的进度
- 6. 跟踪celery.group任务的进度?
- 7. 角度事件跟踪
- 8. 如何跟踪linux命令的进度?
- 9. Android/Java:如何跟踪InputStream的进度
- 10. 如何跟踪AVAssetWriter的写作进度?
- 11. 如何等待从服务角度2
- 12. 跟踪QA的进度
- 13. 跟踪HTTPWebRequest的进度
- 14. 角度2警报服务
- 15. 上传HTTP进度跟踪
- 16. Flowplayer视频进度跟踪?
- 17. NSURLSession dataTaskWithRequest进度跟踪
- 18. Angular $ http,$ q:跟踪进度
- 19. 多线程跟踪进度
- 20. 如何在Linux中跟踪pthread调度?
- 21. ng-options跟踪使用角度1.3.0
- 22. 在客户端跟踪Nodejs服务器进度
- 23. 角度跟踪的hashKey不打印
- 24. 角度巨大的堆栈跟踪
- 25. 角度2服务的清理代码
- 26. Firebase托管服务中的角度2
- 27. 使用vba跟踪http发布进度
- 28. 在服务调用角度后得到未定义的值2
- 29. 全局调用角度服务
- 30. 多次调用角度服务功能
确定。所以我的问题是,那么你将不得不使用可观察的来管理组件中的百分比? – arcee123
@ arcee123您可以使用EventEmitter发出新的百分比值,并在视图中使用的组件中订阅它(更新后的代码)。 – codef0rmer