S
S
skiedr2018-10-09 20:26:19
Angular
skiedr, 2018-10-09 20:26:19

What is the best way to implement nested forms for a single page application?

Let's say we have a form (let's take it as an example) Address (Country, City, ...). When creating an address, you need to make it possible to create a Country, City in a separate form (since there may be many fields) and return the value to the original form, continue filling in the value. At the same time, the same process can take place in the forms Country and City. Which pattern is best suited for this task. What is the best way to implement this in Angular.
I'll clarify the question. At some level, we have a multi-step scenario. At any moment, we can run a subscript that returns a result (for the user, this may look like a new input or search form). The problem is that the scripts are nested, and a subscript for adding something can also be a top-level script.
Actually I want an architectural solution for SPA. For an AJAX server application, this is quite easy to do with modals. Is it possible in Angular (or Vue) to use Router for modal windows.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey K, 2018-10-10
@kuftachev

The difference between a fat client and all sorts of squishies is that the fat one has a fortune, which he carefully keeps. Once you understand this, the answer becomes obvious.
There is a state, it doesn't matter - it's either a storage number, or a top-level component. Then you do all the actions that you need and collect data from the user into this state, and then, when you finish, everything is sent to the server together.
Taking into account state saving, then you can organize the view itself as you like, or render different elements on the same URL, or do routing / subrouting.
PS If the example with cities is real, then you can generally take the maps API from Google or Yandex, the client enters the city and address, he is shown a point on the map, then under this point you get full data about the place with a bunch of additional information, then it may come in handy, although save the postal data itself, which you need. In this case, you will not need to use the SPA features at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question