0

I am not able to use patchValue on the input of a form group control. I have tried this :

  <mat-form-field>
     <mat-label>Duration (HH:MM)</mat-label>
     <input matInput type="time" formControlName="durationCtrl">
  </mat-form-field>
this.myGroup.get('durationCtrl').patchValue('20:20')

and this

this.myGroup.patchValue({
    durationCtrl: "0:20"
})

I'm able to read from the form. When I read it after setting it manually, it returns a string in the format HH:MM, like "04:20". Is there anything I'm doing wrong?

Edit: turns out the issue is purely visual, the value of the control is what it's supposed to be but it does not display the corresponding value. Still a problem but now I have no idea how this can happen.

NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
JGauthier
  • 261
  • 3
  • 6
  • Try this: this.myGroup.patchValue({durationCtrl: newvalue}) –  Sep 22 '20 at 21:43
  • did not work unfortunately. i'll still change to this because it looks more clean, thanks – JGauthier Sep 22 '20 at 21:47
  • here You have example https://stackblitz.com/edit/angular-ivy-avwa3m?file=src/app/app.component.ts and if You have diferent time like you set check localization, –  Sep 23 '20 at 10:00
  • I see with this example that the problem must be somewhere else, i'll look around and see. many thanks ! – JGauthier Sep 23 '20 at 20:14

0 Answers0