How to convert data to Angular?

Asked

Viewed 29 times

0

I have this date in string format:

Sun May 16 2021 09:54:25 GMT-0300 (Horário Padrão de Brasília)

And I want to put it in the front-end form:

<div class="ui-grid-col-6">
      <vale-calendar  [showTime]="true" [showSeconds]="true"
          [showIcon]="false" formControlName="dataFim" [locale]="appService.locale" icon="fa fa-calendar" name="dataFim"></vale-calendar>
</div> 

To put the value in the form I am using the value of element.value. The value of element.label is dataFim

element.value === null ? this.form.controls[element.label].setValue(null) : this.form.controls[element.label].setValue(element.value);

Error obtained:

ERROR Error: Uncaught (in Promise): Missing number at position 0

What am I doing wrong?

1 answer

0

all right?

Unfortunately I’m missing some information to help you with a little more detail, but I’ll try to help you anyway.

What would that be element.value? He’s a class property?

In addition, it would be necessary to verify the date format that this component vale-calendar receives. It may be that he needs to receive this information in a different format than what you are going through. If this is the case, you can use the methods available in the Date Javascript itself to format this date.

I hope I helped a little.

Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.