I'm using angular 4 with ngrx-store and ngrx-effects. I have a simple form to load user information and got it working with effects that then dispatch a Load_User_success action to update the store.
I have a question. What is the best way the load the information to fill the dropdown lists that the form has and at the same time load the user information using ngrx ?
Create an observable in your component and set it equal to a select from the store.
users$ = store.select(state => state.users);
Add the below to component definition
@Component({changeDetection: ChangeDetectionStrategy.OnPush})
Then use an async pipe in your template to handle the subscription with something like:
<div *ngIf="users$ | async">
<select>
<option *ngFor="user of (users$ | async)">{{user.name}}</option>
</select>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.