Angular 获得超过 30 个结果

时间:2021-07-09 10:53:58

标签: angular restangular

我正在尝试获取一张表的所有数据并对其进行 Excel 处理。我有几个问题。我在我的服务中使用了 Restangular。我在quote.service.ts中做了一个getAll函数

getAll(): Observable<Quotation[]> {
    return this.rg.all('quotations').getList();
  }

当我尝试获取它时,我会在我的 component.ts 中执行此操作:

exportAsXLSX(): void {
    this.quotationService.getAll()
      .subscribe(quotations => this.quotations = quotations);
    //console.log(this.quotations);
  }

当我尝试访问 this.quotations 时,它是未定义的。然后我尝试:

exportAsXLSX(): void {
        this.quotationService.getAll()
          .subscribe(quotations => console.log(quotations ));
        //console.log(this.quotations);
      }

我得到了一个结果,但是当我希望我的所有行 (~1400) 都执行 Excel 时,我最多只能得到 30 个结果。我不明白为什么我只得到 30 个结果,为什么当我尝试访问 this.quotations 时,它是未定义的。

编辑:所以 30 个最大结果确实是因为 API。但我仍然有问题

<块引用>

console.log(this.quotations);

未定义,当我可以检查引用是否是我正在寻找的正确数据时。

邮递员的数据是这样的,但我不会把所有的都放上来,因为有私人数据:

{
    "data": {
        "@context": "/api/contexts/Quotation",
        "@id": "/api/quotations",
        "@type": "hydra:Collection",
        "hydra:member": [
            {
                "@id": "/api/quotations/1",

1 个答案:

答案 0 :(得分:0)

好吧,我终于明白了。我用过

@Input() quotations: Quotation[];

在我应该使用的 component.ts 中

quotations: Quotation[];

现在工作正常。

相关问题