Disabled error ao utilizar junto com formcontrolName: The 'value' should be a Valid Javascript Date

Asked

Viewed 28 times

0

I need a datepicker disabled, he owns a formControlName because its value is changed according to the requests:

<kendo-datepicker disabled formControlName="AgendaData"></kendo-datepicker>

The problem is that this way I get a Warning on the console:

It looks like you’re using the disabled attribute with a reactive form Directive. If you set disabled to true when you set up this control in your Component class, the disabled attribute will Actually be set in the DOM for you. We recommend using this approach to avoid 'changed after checked' errors.

  Example: 
  form = new FormGroup({
    first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
    last: new FormControl('Drew', Validators.required)
  });

I tried to do it in my form group as it shows, but it didn’t work.

I tried something like:

  AgendaData: new FormControl({new: new Date(), disabled: true}, [Validators.required]),

But this way I have:

The 'value' should be a Valid Javascript Date

I also tried to:

Agendadata: new Formcontrol({new: new Date(Date.now()), disabled: true}, [Validators.required]),

  • 1

    tries to take html disable from its component

  • I’ve taken and I’m trying to treat on ts, but I have the console errors as shown in the post!

  • 1

    You have tried <Kendo-datepicker formControlName="Agendadata"></Kendo-datepicker>? even though you give Warning?

  • yes, the point is that I need it to be disabled, but when I try to build the formgroup returns the warnings I put in the post

  • 1

    Agendadata: new Formcontrol({value: new Date(), disabled: true}, [Validators.required]) changes there from new to value

  • It worked, if you want to add your answer

Show 1 more comment

1 answer

1


Change there from new to value

AgendaData: new FormControl({value: new Date(), disabled: true}, [Validators.required])

And remove disabled from your html.

Browser other questions tagged

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