Как исправить строки с данными ngx, чтобы они появлялись? - PullRequest
0 голосов
/ 25 июня 2019

ngx datable не будет отображать строки, только заголовок столбца.данные обновляются, но не привязываются к строкам в формате html.

html:

<div class="columns">
        <div class="column col-12">
                <ngx-datatable
                [rows]="rows"
                [columns]="columns"
                [rowHeight]="50">
                </ngx-datatable>
        </div>
</div>

машинопись:

export class CurrencyResultsComponent implements OnInit, OnChanges {

  @Input() amount: number;
  @Input() countryName: string;
  @Input() rates: Rate[];
  @Input() selectedcountry: string;

  public columns = [
    { amount: 'Amount' },
    { name: 'Country' },
  ];

  rows: DispRate[] = [];

  constructor() {
  }

  ngOnInit() {
  }


  ngOnChanges(changes: SimpleChanges) {
    if (changes.rates && changes.rates.currentValue !== changes.rates.previousValue)  {
      for (const key of Object.keys(this.rates)) {
        const dataObj = {
          'amount': this.rates[key] * this.amount,
          'name': key
        };
        this.rows.push(dataObj);
      }
    }
  }
}

ожидается: таблица отображается действительной: данные не отображаются

1 Ответ

0 голосов
/ 25 июня 2019

Добавление this.rows=[...this.rows]; после цикла for-of обновит привязку к строкам ngx-datable

...