TNG / ngqp

Declaratively synchronize form controls with the URL

Home Page:https://tng.github.io/ngqp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Partition URL parameters

Airblader opened this issue · comments

What's your idea?

We now have the option to partition parameters such that one form control is bound to multiple URL parameters. It could also be useful to allow the reverse, that is one URL parameter to encode multiple parameters bound to separate form controls. This would be particularly useful in combination with #89.

Describe the solution you'd like

We need to investigate a good API for this.

An immediate thought that definitely hasn't developed very much yet:

  1. A new type of parameter much like PartitionedQueryParam, but with a URL param and the child parameters
  2. Allow queryParamName to deep select into it (queryParamName="partitioned.name")

One certainly awkward thing here would be that the child parameters would still need URL parameters although those don't get used.

We could also specify this in the group level settings, e.g. by defining which parameters to combine and how. This would also require useless URL parameters for the individual parameters still, though.

It is not clear to me how to create a parameter group for a multiple select mat-select. Which param function, e.g. stringParam() should be used?

I have a multiple select mat-select. It's value is a Array. How can I handle this?

We also have a component that implements ControlValueAccessor whose value is Array. Not sure how to set this up.

@broweratcognitecdotcom This can actually be achieved by using the multi option, you can find documentation and an example here: https://www.ngqp.io/#/docs/configuration/query-param#multi

Let me know if you have further questions!

I have a component that implements ControlValueAccessor. It's value is Array. It will contain either one number, or two numbers (a range). How do you recommend that I handle it? With a serializer/deserializer?

That depends – if the array represents a single value, I would use (de-)serializers. If the array represents multiple values then you should use multi: true.