primeng icon indicating copy to clipboard operation
primeng copied to clipboard

p-inputMask with angular 8 doesn't set value

Open truadeveloper opened this issue 7 years ago • 11 comments

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.

truadeveloper avatar Jul 23 '19 06:07 truadeveloper

I have the same problem.

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

they set but doesnt show...

any solution?

adelcioml avatar Jul 30 '19 15:07 adelcioml

I'm having the same problem.

sergiogoncalves avatar Aug 08 '19 20:08 sergiogoncalves

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.

kt215 avatar Aug 08 '19 23:08 kt215

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

leonetosoft avatar Aug 18 '19 21:08 leonetosoft

Is ivy enabled?

cagataycivici avatar Aug 23 '19 12:08 cagataycivici

ivy not enabled

truadeveloper avatar Aug 23 '19 14:08 truadeveloper

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);
});

Da13Harris avatar Aug 26 '19 19:08 Da13Harris

Commit 35ba346 fixed my ExpressionChangedAfterItHasBeenCheckedError issue too.

kt215 avatar Sep 04 '19 19:09 kt215

I have the same problem on Angular 9 and PrimeNG 9.04

zakharenkov avatar Apr 02 '20 10:04 zakharenkov

I have the same problem on Angular 9 and PrimeNG 9.04

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

ZVARKO avatar Apr 08 '20 12:04 ZVARKO

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

lmorelato avatar Aug 07 '20 02:08 lmorelato