如何解决角度误差

时间:2020-03-16 09:27:02

标签: javascript angular typescript

我想删除登录的当前用户,这就是我使用过滤器的原因。 但我收到一个错误:

类型'Subscription'缺少类型'Observable []>'中的以下属性:_isScalar,源,运算符,提升和另外6个。

这是代码:

@Select(UserPageState.get('collection')) users$: Observable<Array<Partial<User>>>;
async ngOnInit() {
  const USER = this.creds.credentials['id'];
  this.users$.subscribe(param => param.filter(x => x.id !== USER));
  await this.store.dispatch(new UserPageList({ start: 1, length: this.pageSize })).toPromise();
}

HTML

<ag-grid-angular
      style="width: 100%; height: 100%;"
      [class]="(darkMode$ | async) ? 'ag-theme-balham-dark' : 'ag-theme-balham'"
      [gridOptions]="gridOptions"
      [rowData]="users$ | async"
      [columnDefs]="columnDefs"
      [frameworkComponents]="frameworkComponents"
      (gridReady)="onGridReady($event)"
      (firstDataRendered)="onFirstDataRendered($event)"
    >
    </ag-grid-angular>

1 个答案:

答案 0 :(得分:0)

问题在下面的语句中,订阅一个observable返回一个Subscription实例,然后您再次将其分配给observable。

this.users$ = this.users$.subscribe(param => param.filter(x => x.id !== USER));

只需不再将其分配给可观察对象,它将解决此问题。

this.users$.subscribe(param => param.filter(x => x.id !== USER));