小编Avi*_*hek的帖子

如何获取数组缓冲区对象的 mime 类型?

我正在开发一个 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 类型是在上传时将其存储在变量中。但现在的情况是我手里没有任何哑剧类型,所以我需要一种方法来获取它。

这是我的响应标头: 标头

这是我的响应正文示例: 身体

有人能给我建议吗?

javascript blob file-upload arraybuffer angular

7
推荐指数
1
解决办法
8398
查看次数

Angular Material:Mat Table 有时会实时更新有时不会

我有一个调用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)

typescript angular-material angular angular9 mat-dialog

5
推荐指数
1
解决办法
368
查看次数

如何使 mat-dialog 中的按钮也能在 Enter 上工作?

我有一个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 方法,

有人可以提出这个问题吗?

typescript angular-material angular-material2 angular

5
推荐指数
1
解决办法
5863
查看次数