ui-persistence
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

UI Persistence

Provides a declarative way to save and restore component properties of your Angular application or module.

Usage

Import the dependency in you app.module.ts.

import { UiPersistenceModule } from 'ui-persistence';

List it in the declaration array of the NgModule annotation.

@NgModule({
  ...
  imports: [
    ...
    UiPersistenceModule
  ],
  ...
})

Let us say you have a component 'AComp' having a property 'aProp' and you want to save its value when it changes and want it to restore when you reload the application.

In your template you are using this property, so you have something like:

...
<some-tag [value]="aProp" (event)="handlerThatModifiesTheProp($event)"></some-tag>
...

All you have to do is add following element in the template:

<ui-persist [what]="aProp" [key]="'someUniqueKey'" (onLoad)="aProp = $event"></ui-persist>

The position of the element does no matter. I put it on the end of the tamplate usually.

The value of someUniqueKey should could me made up of the schema:

<application_name>.[<module_name>].<component_name>.<property_name>

Github

https://github.com/zsizsik/angular-modules

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i ui-persistence

    Weekly Downloads

    3

    Version

    2.0.0

    License

    none

    Unpacked Size

    38.5 kB

    Total Files

    19

    Last publish

    Collaborators

    • zsizsik