小编cyb*_*ast的帖子

未捕获的TypeError:无法添加属性12,对象不可扩展

我似乎无法理解我在客户端应用程序上遇到的错误.我正在订阅graphql订阅,我能够检索更新,但我无法将更改推送到名为"models:ModelClass []"的视频脚本数组,该数组绑定到视图.

有什么我遗失或做错了吗?

models.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);
});
Run Code Online (Sandbox Code Playgroud)

模型class.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;
}
Run Code Online (Sandbox Code Playgroud)

javascript typescript graphql-subscriptions apollo-client

6
推荐指数
1
解决办法
2721
查看次数

NGRX 效果中的访问状态

如何在效果中访问我的状态?我当前的效果实现(如下所示)是在SEARCH_REUQUEST分派动作时触发的。但是,在调用我的搜索服务以启动 HTTP 请求之前,我想访问一个状态以获取一些搜索参数。

@Effect()
SearchRequest$ = this.actions$
  .ofType(fromSearchActions.SearchActionTypes.SEARCH_REQUEST)
  .pipe(
    switchMap((action: fromSearchActions.SearchRequest) => {
      return this.searchService
        .search(action.payload, action.enrichmentId)
        .pipe(
          map(response => {
            console.group("SEARCH effects");
            console.log(response);
            console.groupEnd();
            return new fromSearchActions.SearchRequestSuccess(response);
          }),
          catchError(error =>
            of(new fromSearchActions.SearchRequestFail(error))
          )
        );
    })
  );
Run Code Online (Sandbox Code Playgroud)

显然,我可以在这里利用一个 RxJS 运算符,但我似乎无法理解如何修改现有的效果实现以合并它。

@Effect()
SearchRequest$ = this.actions$
  .ofType(fromSearchActions.SearchActionTypes.SEARCH_REQUEST)
  .withLatestFrom(this.featureStore.select(fromFeature.getCurrentSearchPageOptions))
  .pipe(
      switchMap((// How should this change? //) => { //Error
        return this.searchService
          .search(action.payload, action.enrichmentId, pageOptions)
          .pipe(
            map(response => {
              console.group("SEARCH effects");
              console.log(response);
              console.groupEnd();
              return new fromSearchActions.SearchRequestSuccess(response);
            }),
            catchError(error =>
              of(new fromSearchActions.SearchRequestFail(error))
            ) …
Run Code Online (Sandbox Code Playgroud)

ngrx ngrx-effects angular ngrx-store-4.0

6
推荐指数
2
解决办法
4462
查看次数

在 Angular5/6 的 onload 方法之外访问文件阅读器内容?

我正在尝试读取具有以下代码片段的文件。

readFile(file: File) {
    var reader = new FileReader();
    console.log(reader.readyState);
    reader.onload = () => {
        console.log(reader.result);
    };
    reader.readAsText(file);
}
Run Code Online (Sandbox Code Playgroud)

正如预期的那样,console.log() 在阅读器的 onload 事件中打印文件的内容。但是,我试图从我的readFile方法中提取此输出作为返回值。

例如,

onSubmit() {
    let output = this.readFile(this.newImportForm.value.dataFile);
    console.log(output);
}
Run Code Online (Sandbox Code Playgroud)

如何将文件内容作为字符串返回?我可以组合一个涉及发射事件和做一些复杂事情的解决方案,但我想探索一个更优雅的解决方案。

提前致谢 :)

typescript angular

3
推荐指数
1
解决办法
1023
查看次数

动态设置 mat-expansion-panel 的高度

我正在尝试使用 a mat-expansion-panel,但是,对于我正在处理的项目,我需要在每个面板上设置的标题长度可能会很长,并且在大多数情况下无法预测。目前,如果标题文本的长度太长,则会超出面板的范围。

我知道我可以设置[collapsedHeight][expandedHeight]属性来调整此行为,但是,我正在尝试寻找一种不会对值进行硬编码的解决方案。

这是StackBlitz演示我正在谈论的内容。其中,第一个扩展面板显示了当标题内容太长并且未设置时会发生[collapsedHeight]什么[expandedHeight]。第二个扩展面板显示了当我将其设置为静态值 - 时会发生什么190px

实现这一目标的最佳方法是什么?

javascript css angular-material angular

3
推荐指数
1
解决办法
1万
查看次数

Jenkins - 如何在声明性管道中指定 Active Choice Reactive 参数?

我正在尝试实现一个 Jenkins 管道,借此我想控制 git 中管道代码的源代码。

要在声明性管道中声明我的参数,我必须遵守以下语法:-

...
pipeline {
    parameters {
        ...
    }
...
}
Run Code Online (Sandbox Code Playgroud)

对于参数部分,如何声明 Active Choice Reactive 参数,以便我可以使用 groovy 脚本以编程方式填充选项?

我知道使用 Jenkins UI 使用管道选项可以实现这一点Configure,但是我试图了解如何在 Groovy 代码中实现此行为。

谢谢

groovy jenkins

3
推荐指数
1
解决办法
6641
查看次数

如何在 Google Cloud Platform VM 上启用 VT-X/AMD-v?

我正在尝试在 GCP VM 上安装 Minikube。我遇到了操作系统抱怨需要启用 VT-X/AMD-v 的问题。是否有任何具体说明可以在 GCP 上进行设置?

google-cloud-platform kubernetes minikube

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