Answer the question
In order to leave comments, you need to log in
How would you organize the component structure?
I have several HTML sections which contain form elements (select, input, texarea, checkbox).
Each section can be designed as a separate component.
The task is to collect the selected values from each section and collect the url for the filter.
Let's say that each component has an input @Input
, which forms a form, and an output, selected values @Output
.
It can also be assumed that there is some class that generates a url (string) for each selected value from each component.
Based on this, there must be a parent component - listening, managing child (sections - components).
All this is complicated by the fact that each section has its own rules for generating url based on the form.
For example, if there are fields with dates in the "Date of production" section, but at the output, if they are filled, you need to form a url string like:
filter?dateStarrt[lt]=value&dateEnd[gte]=value
.
From the other section, only the values of the selected checkboxes can arrive, as an array. In this case, the filter is supplemented with the values:
filter?dateStarrt[lt]=value&dateEnd[gte]=value&import=1,3,4[in]
. <input type="text" name="build_year__lte" placeholder="до" tabindex="0" value="">
Answer the question
In order to leave comments, you need to log in
For each component required in a filter such as date, implement the ControlValueAccessor interface, and optionally a Validator for validation.
The value of such a FormControl would be:
startDate: x,
endDate:y
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question