Querying Lists Easily with ListService

    ListService is not provided in root. The reason is, this way, it will clear any subscriptions on component destroy. You may use the optional LIST_QUERY_DEBOUNCE_TIME token to adjust the debounce behavior.

    Bind ListService to ngx-datatable like this:

    1. <ngx-datatable
    2. [rows]="items"
    3. [count]="count"
    4. [list]="list"
    5. default
    6. >
    7. <!-- column templates here -->
    8. </ngx-datatable>

      …or…

      1. @Select(BookState.getBooks)
      2. books$: Observable<BookDto[]>;
      3. @Select(BookState.getBookCount)
      4. bookCount$: Observable<number>;
      5. ngOnInit() {
      6. this.list.hookToQuery((query) => this.store.dispatch(new GetBooks(query))).subscribe();
      7. }
      1. <!-- simplified representation of the template -->
      2. <ngx-datatable
      3. [rows]="(books$ | async) || []"
      4. [list]="list"
      5. default
      6. >
      7. <!-- column templates here -->
      8. </ngx-datatable>

      ListService exposes a get method to trigger a request with the current query. So, basically, whenever a create, update, or delete action resolves, you can call this.list.get(); and it will call hooked stream creator again.

      ListService exposes a filter property that will trigger a request with the current query and the given search string. All you need to do is to bind it to an input element with two-way binding.

      1. <!-- simplified representation -->
      2. <input type="text" name="search" [(ngModel)]="list.filter">

      We had to modify the ListService to make it work with ngx-datatable. Previously, the minimum value for page property was 1 and you could use it like this:

      1. <!-- other bindings are hidden in favor of brevity -->
      2. <abp-table
      3. [page]="list.page + 1"
      4. (pageChange)="list.page = $event - 1"

      Important Note: The abp-table is not removed, but is deprecated and will be removed in the future. Please consider switching to ngx-datatable.