我正在开发一个 API,它以arraybuffer类型的形式获取文件数据。我的主要问题是知道文件的 mime 类型是什么,因为arraybuffer我需要将其转换为BLOB查看文件。
var file1 = new Blob([response], { type: file.type });
var fileURL = URL.createObjectURL(file1);
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中,response是 an arraybuffer,我得到的 mime 类型是在上传时将其存储在变量中。但现在的情况是我手里没有任何哑剧类型,所以我需要一种方法来获取它。
有人能给我建议吗?
我有一个调用GET请求的垫表。另外,我有一个 Mat Dialog,它接收数据并保存点击调用POST请求。一切正常,但有时在我单击“保存”按钮后表格会更新,但有时不会(我必须重新加载页面并查看它更新)。
mat-dialog.component.ts
onSubmit() { // This method is called on the button click in Mat-Dialog
if(this.formdata.invalid) {
return;
}
this.adminService.createQuestionCategory(this.formdata.value).subscribe(reponse => {
this._snackBar.open('New Question Category Added Successfully', '', {
duration: 7500,
horizontalPosition: this.horizontalPosition,
verticalPosition: this.verticalPosition
});
});
}
Run Code Online (Sandbox Code Playgroud)
main.component.ts
constructor(private adminCategory: AdminCategoryService, private fb: FormBuilder, public dialog: MatDialog) {
dialog.afterAllClosed.subscribe(() => {
console.log(''); // This line gets called everytime on close of the modal
this.getTableData(); // So this line also gets called but not …Run Code Online (Sandbox Code Playgroud) 我有一个mat-dialog-box点击事件,它会关闭对话框,但我希望它能够工作Enter也能在按下时工作。有什么办法可以做到吗?
我尝试过使用表格,但没有成功。以下是我尝试使用的解决方案:
超文本标记语言
<form (submit)="doAction()">
<button type="submit">Add</button>
</form>
Run Code Online (Sandbox Code Playgroud)
TS
doAction() {
this.dialogRef.close({ event: this.action, data: this.local_data });
}
Run Code Online (Sandbox Code Playgroud)
但是,Enter尽管单击它正在提交数据,但该事件并未发生。也适用于普通形式(不在对话框中)Enter如果我采用上述 HTML 方法,
有人可以提出这个问题吗?
angular ×3
typescript ×2
angular9 ×1
arraybuffer ×1
blob ×1
file-upload ×1
javascript ×1
mat-dialog ×1