Comments (6)
Hi, thanks for opening this issue. Is the isSingle()
decided once when the component loads, or can this change at any point in time?
from ngqp.
Sorry for the late reply. It could be changed all the time.
I believe it is one of the situation of # #145
from ngqp.
It could be changed all the time.
I think that would make it awkward if you currently have a multi: true query param with a value of [1, 2]
and now want to disable multi. ngqp couldn't know what you'd want to do with the value, and any strategy like "pick the first one" seems like a workaround.
However, can't you do something like this for your case?
private singleParam = this.qpb.param('p');
private multiParam = this.qpb.param('p', {multi: true});
private paramGroup = this.qpb.group({
param: singleParam,
});
switchParam(multi: boolean) {
const currentParam = this.paramGroup.get("param");
this.paramGroup.remove("param");
const newParam = multi ? this.multiParam : this.singleParam;
// This probably requires a type assertion, I cannot actually try it out right now
newParam.setValue(currentParam.value);
this.paramGroup.add("param", newParam);
}
On a side note, ngqp doesn't usually work well in combination with template-driven or reactive forms (you're using both queryParamName and formControl).
from ngqp.
Yea, it is a good idea to drop the old one and add a new one without multi property. I will try that out and hope it works. Thank you for your help! :)
from ngqp.
You're welcome! Once you have tried it out please feel free to post back here whether it worked / what else was needed to make it work.
I'll close this issue for now given that solution and the fact that I don't think the original feature can be implemented in a nice way. We can certainly reconsider if the solution above doesn't work out.
from ngqp.
I forgot to leave the feedback! The remove / add new control works, just need to find the correct time to do so.
from ngqp.
Related Issues (20)
- Partition URL parameters HOT 6
- Programmatically set value of parameters inside a partition
- emptyOn + multi leads to incorrect behavior HOT 1
- Provide the entire array to (de-)serializers for multi params
- Combination of `multi` and normal parameter breaks `valueChanges` HOT 4
- Need Ivy support HOT 5
- valueChanges Observable from one param is leaking Events from other params of the same group. HOT 6
- Synchronize router based on manual trigger HOT 2
- Programmatically delete/remove/reset queryForms and queryParams HOT 7
- How to have custom values in select dropdowns? HOT 9
- No chance to access first value of paramGroup on component load HOT 3
- Expose a replayed value$ observable HOT 2
- Sync URL with nested QueryParamGroup HOT 4
- Update version support on website
- Update to support Angular 13 HOT 2
- 'QueryParamModule' does not appear to be an NgModule class HOT 4
- Proper support of angular 14+ (Not working in angular 16 due to absent ngcc) HOT 7
- Types of property 'serialize' are incompatible HOT 2
- Angular 16 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngqp.