Socket
Socket
Sign inDemoInstall

@s-libs/ng-app-state

Package Overview
Dependencies
10
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @s-libs/ng-app-state

Painlessly integrate [`app-state`](https://github.com/simontonsoftware/s-libs/projects/app-state) into template-driven Angular forms.


Version published
Weekly downloads
557
increased by33.25%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

15.1.0 (2023-01-16)

Features

  • js-core: add getCombinations() (a1ec141), closes #84
  • ng-dev: add AngularContext.getHarnessOrNull() (c2bb4ba), closes #88
  • ng-mat-core: add helpers to set up complex themes easily (0879e43)

Bug Fixes

  • ng-dev: AngularContext cleans up after itself better in error situations, to avoid all future tests failing "There is already another AngularContext in use (or it was not cleaned up)" (81cbd5c), closes #98

Readme

Source

Painlessly integrate app-state into template-driven Angular forms.

Installation

Install along with its peer dependencies using:

npm install --save @s-libs/ng-app-state @s-libs/app-state @s-libs/ng-core @s-libs/rxjs-core @s-libs/js-core @s-libs/micro-dash

# OR

yarn add @s-libs/ng-app-state @s-libs/app-state @s-libs/ng-core @s-libs/rxjs-core @s-libs/js-core @s-libs/micro-dash

Setup

In your module, import NasModelModule, e.g.:

// app.module.ts

import { NasModelModule } from "@s-libs/ng-app-state";

@NgModule({
  imports: [NasModelModule],
})
export class AppModule {}

Template Driven Forms

This library includes the [nasModel] directive that you can use in place of [(ngModel)] to bind form controls directly to store objects. For example, to edit the current user's name in the example above:

@Component({
  template: `<input [nasModel]="nameStore" />`,
})
class AccountSettingsComponent {
  nameStore: Store<string>;

  constructor(myStore: MyStore) {
    this.nameStore = myStore("currentUser")("name");
  }
}

[nasModel] is tested to work with all standard form controls. Except where noted, they all bind to Store<string> objects.

  • <input type="checkbox"> - binds to Store<boolean>
  • <input type="color">
  • <input type="date">
  • <input type="datetime-local">
  • <input type="email">
  • <input type="month">
  • <input type="number"> - binds to Store<number>
  • <input type="password">
  • <input type="radio">
  • <input type="range"> - binds to Store<number>
  • <input type="search">
  • <input type="tel">
  • <input type="text">
  • <input type="time">
  • <input type="url">
  • <input type="week">
  • <input>
  • <select multiple> - binds to Store<string[]>
  • <select>
  • <textarea>

FAQs

Last updated on 16 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc