FormArray分页

时间:2018-09-16 11:56:23

标签: angular angular-forms

我有一个formArray:

this.tableRules = this._fb.group({
  rules: this._fb.array([])
});

  get rulesArray(){
    let rules = this.tableRules.get('rules') as FormArray;
    return rules;
  }

我想使用在下面创建的管道进行分页无法理解如何实现它:

import { Pipe, PipeTransform } from '@angular/core';
import { Rule } from './rule';
import { FormArray, FormGroup, FormControl } from '@angular/forms';

@Pipe({
  name: 'pagination',
  pure:false
})
export class PaginationPipe implements PipeTransform {

  transform(value: FormArray, pageSize : string , pageNumber : string): any {
    let startIndex = (parseInt(pageNumber)- 1) * parseInt(pageSize);
    let endIndex = startIndex + parseInt(pageSize);
    return value;
  }

} 

在我的html中,我是这样使用的:

<div formArrayName="rules" *ngFor="let rule of rulesArray.controls | pagination : '10' : '1'; let i = index;">

任何帮助表示赞赏。 谢谢

0 个答案:

没有答案