筛选项目FormArray

时间:2018-08-13 18:24:42

标签: angular filter

我有一个具有以下结构的FormArray:

this.salesListArray = this.modeloForm.get('id_listas') as FormArray;

result.forEach(element => {
let formGroup: FormGroup = this.fb.group({
    checked: this.fb.control(false),
    id_lista: this.fb.control(element.id_lista[0]),
    nombre: this.fb.control(element.nombre),
    codigoInterno: this.fb.control(element.codigo_interno),
    porcentaje_original: this.fb.control({ value: element.porcentaje_revision, disabled: true }),
    porcentaje: this.fb.control(element.porcentaje_revision, [Validators.min(10), Validators.max(100)]),
    auditoria_original: this.fb.control({ value: element.porcentaje_auditoria, disabled: true }),
    auditoria: this.fb.control(element.porcentaje_auditoria, [Validators.min(10), Validators.max(100)]),
});

this.salesListArray.push(formGroup);

我需要能够通过nombre的值来过滤输入,

尝试这样的事情:

@Pipe({ name: 'filter' })
export class FilterPipe implements PipeTransform {
  public transform(values: any[], filter: string): any[] {
   if (!values || !values.length) return [];
   if (!filter) return values;

   return values.filter(v => v.value.nombre.indexOf(filter) >= 0);
  }
}

但是,我无法获得这些项目,对其进行过滤,但值都为空

0 个答案:

没有答案