Code Monkey home page Code Monkey logo

Comments (6)

Airblader avatar Airblader commented on July 3, 2024

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.

Duke-Rong avatar Duke-Rong commented on July 3, 2024

Sorry for the late reply. It could be changed all the time.
I believe it is one of the situation of # #145

from ngqp.

Airblader avatar Airblader commented on July 3, 2024

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.

Duke-Rong avatar Duke-Rong commented on July 3, 2024

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.

Airblader avatar Airblader commented on July 3, 2024

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.

Duke-Rong avatar Duke-Rong commented on July 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.