MatTableDataSource未使用_updateChangeSubscription()方法

时间:2019-05-28 17:49:35

标签: angular angular-material

我有一个包含一些数据的MatTableDataSource。当我执行“更新”时,我使用名为“ _updateChangeSubscription()”的方法来更新表,并且可以正常工作。我想知道,当我执行“ POST”或“ DELETE”时如何更新表。我尝试了与上面相同的方法,但没有成功

此方法更新了我的表,因为我正在使用_updateChangeSubscription()

public updateWorkspace() {
        this.workspace['id'] = this.workspace._id;
        this.workspace.createdBy = null;
        this.workspace.createdAt = null;
        this.workspace.updatedBy = this.user;
        this.workspace.updatedAt = new Date();
        this.workspace.language = this.workspaceForm.value.language;
        this.workspace.description = this.workspaceForm.value.description;
        this.workspace.name = this.workspaceForm.value.name;
        this.workspacesService.updateWorkspace(this.workspace).subscribe((response) => {
            alert("SUCESSO")
            this.workspaces._updateChangeSubscription()
            this.workspaceForm.reset(); // fica vermelho os campos
            this.workspace = null;
        }, (error) => {
            alert("Ocorreu um erro ao tentar atualizar o Assunto")
        });
    }

此方法不适用于_updateChangeSubscription()方法

public updateWorkspace() {
        this.workspace['id'] = this.workspace._id;
        this.workspace.createdBy = null;
        this.workspace.createdAt = null;
        this.workspace.updatedBy = this.user;
        this.workspace.updatedAt = new Date();
        this.workspace.language = this.workspaceForm.value.language;
        this.workspace.description = this.workspaceForm.value.description;
        this.workspace.name = this.workspaceForm.value.name;
        this.workspacesService.updateWorkspace(this.workspace).subscribe((response) => {
            alert("SUCESSO")
            this.workspaces._updateChangeSubscription()
            this.workspaceForm.reset(); // fica vermelho os campos
            this.workspace = null;
        }, (error) => {
            alert("Ocorreu um erro ao tentar atualizar o Assunto")
        });
    }

我希望我的所有方法都可以在发布或删除表时独立更新表。

0 个答案:

没有答案