我希望将进度百分比数据从调用组件传递到MatDialog。使用dialogref或在Dialog组件构造函数中注入数据,我只能用初始值设置变量。但是值没有更新,因为它是在调用组件中更新的。
这样做的目的是在对话框中设置一个进度栏,在上传/下载过程中阻止用户的操作。
发布于 2018-09-24 04:48:43
您可以使用shared service或只对您正在启动对话框的模块创建service,在服务创建当前进度的Observable和Subject中,模式应该侦听Observable,而在Subject上只需使用.next(progressValue)更新值。
您可以了解更多的这里,它是关于父级和子级的,但是如果对话框与组件/服务在同一个模块中,就不会有任何问题。
发布于 2019-07-12 05:29:29
使用getObject函数中的download加载进度,您可以检查下载进度。
.on('httpDownloadProgress',(progress) => {
// shows file download progress
});这是包括下载功能在内的全部代码
import { config, SecretsManager, S3 , CognitoIdentityCredentials} from 'aws-sdk';
const bucket = new S3({
accessKeyId: <accessKeyId>,
secretAccessKey: <secretAccessKey>,
region: <region>
});
const params = {
Bucket: <BucketName>,
Key: <fileName>,
};
bucket.getObject(params, (err:any, data:any) =>{
if (err) {
// shows AWS s3 error
}else{
// response of binary data
}
}).on('httpDownloadProgress',(progress) => {
// shows file download progress
});https://stackoverflow.com/questions/52472575
复制相似问题