17.1.0 • Published 4 months ago

@s-libs/ng-app-state v17.1.0

Weekly downloads
240
License
MIT
Repository
github
Last release
4 months ago

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

PLEASE NOTE: signal-store is now available for Angular apps, based on Angular signals instead of RxJS. Its updated design does not require a separate library like this for integration into forms. Instead, with that library you simply use [(ngModel)]="store.state".

Installation

Install along with its peer dependencies using:

npm install @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>
17.1.0

4 months ago

17.0.0-next.2

6 months ago

17.0.0-next.0

6 months ago

17.0.0-next.1

6 months ago

17.0.0

6 months ago

16.1.0

9 months ago

16.0.0-next.0

1 year ago

16.0.0-next.1

1 year ago

16.0.0-next.2

1 year ago

16.0.0

11 months ago

15.2.0

1 year ago

15.0.0

1 year ago

15.1.0

1 year ago

15.0.0-next.0

1 year ago

14.1.0

2 years ago

14.0.0

2 years ago

14.0.0-next.0

2 years ago

13.1.0

2 years ago

13.0.0-next.0

2 years ago

13.0.0

2 years ago

13.1.0-next.2

2 years ago

13.1.0-next.1

2 years ago

13.1.0-next.0

2 years ago

12.0.0

3 years ago

12.0.0-next.1

3 years ago

12.0.0-next.0

3 years ago

11.3.0

3 years ago

11.2.0

3 years ago

11.2.1

3 years ago

11.2.0-next.2

3 years ago

11.2.0-next.1

3 years ago

11.2.0-next.0

3 years ago

11.1.0

3 years ago

11.0.0

3 years ago

11.0.0-next.0

3 years ago

10.0.0

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago