Painlessly integrate [`app-state`](https://github.com/simontonsoftware/s-libs/projects/app-state) into template-driven Angular forms.
npm install @s-libs/ng-app-statePainlessly 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".
Install along with its peer dependencies using:
``shell script`
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
In your module, import NasModelModule, e.g.:
`ts
// app.module.ts
import { NasModelModule } from "@s-libs/ng-app-state";
@NgModule({
imports: [NasModelModule],
})
export class AppModule {}
`
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:
`ts
@Component({
template: ,
})
class AccountSettingsComponent {
nameStore: Store
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 objects.
- - binds to Store
-
-
-
-
-
- - binds to Store
-
-
- - binds to Store
-
-
-
-
-
-
-
-