处理多个变更事件angular4

问题描述 投票:0回答:1

添加一些$事件时,我无法保留其他过滤器中的先前值。

在我的Component.ts中

   handleMemberListChange(value) {
    this.getMappSummaryStatistics = new MappSummaryStatistics();
    this.summaryStatisticsService.getMappSummaryStatistics(value.number, ???)
      .subscribe(res => this.getMappSummaryStatistics = res);
  }
  handleTimeListChange(value) {
    this.getMappSummaryStatistics = new MappSummaryStatistics();
    this.summaryStatisticsService.getMappSummaryStatistics(???, value.timeType)
      .subscribe(res => this.getMappSummaryStatistics = res);
  }

例如:

handleMemberListChange我选择foo1并使用参数并更改数据。

handleTimeListChange我选择poo2但handleMemberListChange不再将foo1作为传递给handleMemberListChange的值,它只是将其清零。

angular
1个回答
0
投票

要详细说明David L所说的内容,您可以执行以下操作来存储foo1的值:

private foo: Foo;

handleMemberListChange(value) {
  this.foo = value;
  // ... rest of the method
}

但根据您的代码和问题,我猜这是您要实现的目标:

private foo: Foo;

handleMemberListChange(value) {
  this.foo.number = value.number; // set number
  this.getMappSummaryStatistics = new MappSummaryStatistics();
  this.summaryStatisticsService.getMappSummaryStatistics(value.number, ???)
    .subscribe(res => this.getMappSummaryStatistics = res);
}
handleTimeListChange(value) {
  this.foo.timeType = value.timeType; // set timeType
  this.getMappSummaryStatistics = new MappSummaryStatistics();
  this.summaryStatisticsService.getMappSummaryStatistics(???, value.timeType)
    .subscribe(res => this.getMappSummaryStatistics = res);
}

这样,您的“过滤器”的值就会被存储,以后可以使用。

© www.soinside.com 2019 - 2024. All rights reserved.