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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ng-fieldmemory

v0.0.6

Published

Save and restore form fields automatically. No boilerplate, no custom wiring — just add an attribute and your inputs remember their values across refreshes and navigation.

Downloads

284

Readme

ng-field-memory

Save and restore form fields automatically. No boilerplate, no custom wiring — just add an attribute and your inputs remember their values across refreshes and navigation.

What it does

  • Saves values as you type to localStorage
  • Restores values on page load automatically
  • Works with inputs, textareas, and selects
  • Lets you save a whole form (object) on submit using a simple service

Install

npm i ng-fieldmemory

Use it

  1. Import the module

Standalone component:

import { NgFieldMemoryModule } from "ng-fieldmemory";

@Component({
  standalone: true,
  imports: [NgFieldMemoryModule],
})
export class MyComponent {}

NgModule:

import { NgFieldMemoryModule } from "ng-fieldmemory";

@NgModule({ imports: [NgFieldMemoryModule] })
export class MyModule {}
  1. Remember a field
<input type="text" ngFieldMemory="user-email" placeholder="Email" />
  1. JSON-friendly fields
<input type="text" ngFieldMemory="user-data" [isJson]="true" placeholder='{"name":"Alex"}' />
  1. Selects and numbers work too
<select ngFieldMemory="page-size">
  <option value="5">5</option>
  <option value="10">10</option>
  <option value="20">20</option>
</select>

<input type="number" ngFieldMemory="current-page" />
  1. Save a whole form on submit
import { NgFieldMemoryService } from 'ng-fieldmemory'

constructor(private memory: NgFieldMemoryService) {}

onSubmit() {
  this.memory.save('profile-form', this.form.value)
  // After a successful POST:
  // this.memory.clear('profile-form')
}

ngOnInit() {
  const saved = this.memory.get<any>('profile-form')
  if (saved) this.form.patchValue(saved)
}

How keys work

  • Each field or form uses a unique key that you choose, like user-email or profile-form.
  • Values are stored under a namespaced key: ng-field-memory:<your-key>.
  • Use the same key on different pages/components to share the same value.

Minimal API you’ll use

Service (NgFieldMemoryService):

  • save(key, value) — store anything JSON-serializable
  • get<T>(key) — read it back (typed)
  • clear(key) — remove it

Directive ([ngFieldMemory]):

  • ngFieldMemory="key" — enable memory for a field
  • [isJson]="true" — store as object/array instead of plain string
  • [memoryDebounce]="500" — debounce ms for saving (default 500)

Good to know

  • Works in the browser; during SSR it falls back to an in-memory store (no crashes).
  • Restores values and notifies Angular so your bindings update.
  • You don’t need to write localStorage code — use the directive or the service.

Troubleshooting

  • Field shows the right value but your UI logic didn’t react?
    • If you’re listening to (change) on a <select>, the library triggers change and input events on load so handlers run. If you have custom logic, make sure it listens to the right event.
  • Want to clear something?
    • memory.clear('user-email') for one key, or change the key to “reset” a field.

License

MIT