我似乎无法理解我在客户端应用程序上遇到的错误。我正在订阅 graphql 订阅,并且能够检索更新,但我无法将更改推送到绑定到视图的名为“models:ModelClass[]”的打字稿数组。
我有什么遗漏或做错了吗?
模型.component.ts
this.apollo.subscribe({
query: gql`
subscription {
newModelCreated{
_id
name
type
train_status
deploy_status
data_path
description
created_at
updated_at
}
}
`
}).subscribe((data) => {
console.log("CREATED: " + JSON.stringify(data.newModelCreated));
console.log(data.newModelCreated);
var temp:ModelClass = data.newModelCreated;
this.models.push(temp);
});
模型类.ts
export interface ModelClass {
_id: string;
name: string;
type: string;
parameters: {
alpha: number;
};
train_status: string;
deploy_status: string;
test_accuracy: string;
created_at: number;
updated_at: number;
}