Primeng: p-inputMask with angular 8 doesn't set value

Created on 23 Jul 2019  路  11Comments  路  Source: primefaces/primeng

in ngOnInit

this.formGroup.setValue(value);

doesn't set p-inputMask value with angular 8 and following p-inputMask code;

@ViewChild('input', { static: false }) inputViewChild: ElementRef;

changing to

@ViewChild('input', { static: true }) inputViewChild: ElementRef;

fix the problem,
also

 setTimeout(() => {
   this.formGroup.setValue(value);
}, 0);

works.

defect

Most helpful comment

Commit 35ba346 fixed my ExpressionChangedAfterItHasBeenCheckedError issue too.

All 11 comments

I have the same problem.

this.formulario.controls['ini'].setValue(moment(Date.now()).format('L'));

they set but doesnt show...

any solution?

I'm having the same problem.

Probably a separate issue, but: I upgraded to Angular 8 and I use p-inputMask with ngrx-forms. Values are set but I see lots of ExpressionChangedAfterItHasBeenCheckedError in the console for the p-inputMask control. These errors did not occur with Angular 7.

Same problem here, I had to do the hack method below:

setTimeout(() => {
        this.formGroup.patchValue({
          descricao: rs.data.prestadorPorId.descricao,
          cnpj_cpf: rs.data.prestadorPorId.cnpj_cpf,
          tipo: rs.data.prestadorPorId.tipo,
          fone: rs.data.prestadorPorId.fone,
          grupoProcedimento: rs.data.prestadorPorId.grupoProcedimentos.map((el) => ({ descricao: el.descricao, value: el.id })),
          prestadorProfissional: rs.data.prestadorPorId.profissionaisExecutantes.map((el) => ({ nome: el.nome, crm: el.codigo_conselho, value: el.id }))
        });
      }, 0);

Angular: 8.0.0
Primeng: 8.0.0

Is ivy enabled?

ivy not enabled

This issue is also occurring for us.

I made a StackBlitz example of the issue. If you comment out the setTimeout(), the value doesn't display.
https://stackblitz.com/edit/github-rz93cx

The hack for us has been to set the control's value to the value that's already in the control, like this:

setTimeout(() => {
  const maskedInputControl = this.parentForm.get('maskedInput') as FormControl;
  maskedInputControl.setValue(maskedInputControl.value);
});

Commit 35ba346 fixed my ExpressionChangedAfterItHasBeenCheckedError issue too.

I have the same problem on Angular 9 and PrimeNG 9.04

I have the same problem on Angular 9 and PrimeNG 9.04

I created issue yesterday https://github.com/primefaces/primeng/issues/8727

I have the same issue on Angular 9.1.4 and PrimeNG 9.1.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gatapia picture gatapia  路  3Comments

SchneMa picture SchneMa  路  3Comments

cyberrranger picture cyberrranger  路  3Comments

lilling picture lilling  路  3Comments

papiroca-tm picture papiroca-tm  路  3Comments