james Makinde
james Makinde

Reputation: 973

Update textbox after change to NGRX store - Two way binding

I am using Angular 6 with NGRX. I updated the value of a field in my NGRX store in the reducer and that works fine. How do I create two way binding so a textbox input field from a form on the UI will also be updated based on that property in the store. I want to have two way binding between my NGRX store and the form input field?

Upvotes: 1

Views: 1010

Answers (1)

Ritesh Waghela
Ritesh Waghela

Reputation: 3727

Your can subscribe to the store property in your component using @select decorator.

Something like this:

@select([YOUR_REDUCER, 'property']) private propertyObs$: Observable<type>;

And in your template you can subscribe to propertyObs using AsyncPipe.

More info on AsyncPipe: https://blog.angular-university.io/angular-reactive-templates.

NgRx Selectors: https://toddmotto.com/ngrx-store-understanding-state-selectors

Upvotes: 1

Related Questions