首页 > 解决方案 > 角度数据表分页不起作用或搜索

问题描述

对于从 web api 绑定的表,我试图使用基于此的角度数据表

所以这是我的组件

import { Component, OnInit } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { PortfolioEpicService } from 'src/app/shared/portfolio-epic.service';
import { PortfolioEpicModel } from 'src/app/shared/portfolio-epic/portfolio-epic.model';


@Component({
  selector: 'app-portfolio',
  templateUrl: './portfolio.component.html',
  styleUrls: ['./portfolio.component.css']
})
export class PortfolioComponent implements OnInit {
  pEpics:any;
  dtOptions: DataTables.Settings = {};
  constructor(private toastr:ToastrService,public service:PortfolioEpicService) { }

  ngOnInit(): void {
    this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 5,
      processing: true
    };
    this.refreshAllPortfolioEpics();
  }

}

因此,正如预期的那样,创建了数据表(只是绑​​定了)。但是没有适当的绑定。我的意思是没有分页、没有搜索或数据表功能都不起作用。 在此处输入图像描述 我做错了什么??

标签: angulardatatablesangular-datatables

解决方案


您链接的示例使用 aSubject<any>作为触发器来通知表重新呈现。

也这样做,它应该按预期工作。


推荐阅读