S
S
Sashqa2020-02-05 15:26:27
Angular
Sashqa, 2020-02-05 15:26:27

Question about form control in Angular?

There is some kind of input field with a control. To me a call of a certain method the request with value from this field is sent.
It is necessary for me that at the very first request this field does not participate in the request, I achieved this by removing the default value in this field.
But this turned out to be the wrong decision. It is necessary that the value be there, but the request was also sent without this field.

I tried to create another control - and when initializing the component, I did it in the method where I need to try to do it like thistestControl = new Form Control()setValue(1)

this.testControl = this.customControl as FormControl


But doesn't work. Plz tell me how to be in this situation

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-02-05
@Sashqa


It is necessary for me that at the very first request this field does not participate in the request, I achieved this by removing the default value in this field.

Explain in more detail why this behavior?
While it looks like you need to check it in the request, the form should not play a role here at all.
And the form always has a default value, if not specified, then it is undefined.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question