A
A
andrkkk2020-03-11 21:03:28
Angular
andrkkk, 2020-03-11 21:03:28

How to dynamically update a table?

There is a component that receives data and sends it to the service, and another (with the ngx-datatable) is subscribed to receive this data:

carsArray = [] 
rows = []
ngOnInit() {
  this.share.currentCarsArray.subscribe( carsArray => {
    this.carsArray = carsArray 
  })
}


It turns out that when the page is loaded, the table is created empty (because the array is empty and there is nothing to fill rows with). How to make a dynamic update so that when an array is received, the table is updated? I didn't understand the documentation.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-03-11
@andrkkk

this.data$ = this.http.get('api/table');

<ngx-datatable
  class="material striped"
  [rows]="data$ | async"
  [columns]="columns"
></ngx-datatable>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question