npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-ui2qp

v2.0.0

Published

Synchronize a form with the browser's URL query params

Downloads

17

Readme

ng-ui2qp

Angular library that synchronizes UI component's state with the Browser's query params, improving the user experience allowing the creation of shareable links.

Description

The lib provides a way of synchronizing UI components' state into query parameters(QPs) using a declarative and familiar approach because it extends Angular ReactiveForms. Using the library's features improves the user experience. Think about the following use cases:

  • Accidentally or intentionally refreshing the page will keep the last state of the app which prevents the user lose the data entered. In mobiles, refreshing the page accidentally happens very commonly.
  • If you want to bookmark or share specific states of the application, you could do it simply copying the url and sending it to who you want or bookmarking the page which guarantees you to restore the page exactly how was.

Advantages

Here are some advantages the lib provides over its peers:

  • Extends ReactiveForms API, which makes the library features very familiar and easy to assimilate.
  • Allows saving and restoring whatever model(or state), including deeply nested models.
  • It's compatible with Angular Validations.
  • Allows dynamically add and remove parts of the model, or replace it for a new one if needed.

Full documentation

Check out the online docs for a full understanding of all the features the library provides.

Installation

The library supports Angular Schematics so just run the following command:

ng add ng-ui2qp

or just use npm:

npm i ng-ui2qp

Import Ui2QpModule

Import the module in the AppModule of the app

NgUi2QpModule

The above code imports the NgUi2Qp module with the default settings, here they are:

{ autoUpdating: {enabled: true, debounce: 500}, replaceState: true, logLevel: LogLevel.Off, cryptoSecretKey: 'Th3M0st5ecureS3cretK3Y' }

How to use

Inject the Ui2QpBuilder service in the component

constructor(private ui2QpBuilder: Ui2QpBuilder) { ... }

Create a Ui2QpGroup and its controls, like it's done when using ReactiveForms

const model = this.ui2QpBuilder.group( { firstName: this.ui2QpBuilder.control(), lastName: this.ui2QpBuilder.control() } );

Instantiate a Ui2QpRoot object and link it to the created model

const root = this.ui2QpBuilder.root(model);

It's possible to do both previous steps in one, here is how:

const root = this.ui2QpBuilder.root( this.ui2QpBuilder.group({ firstName: this.ui2QpBuilder.control(), lastName: this.ui2QpBuilder.control(), }) );

ATTENTION: The Ui2QpRoot holds a subscription to the "valueChanges" observable of the model if the "autoUpdating" setting was enabled, which means the "destroy" method in the Ui2QpRoot must be executed within the "onDestroy" lifecycle-hook of the component where was created, doing it prevents memory leaks.

Bind the model with the template

<ng-container [formGroup]="root.model"> <input formControlName="firstName"> <input formControlName="lastName"> </ng-container>

That's all :)

Limitations

Please keep in mind that for compatibility matters between browsers, we recommend the URL's length doesn't get beyond 2,083 characters because that could cause some unexpected behavior in old browsers. Please read this for more information.