[英]Fill dropdown information with ngrx-store / efffects
我正在使用帶有ngrx-store和ngrx-effects的angular 4。 我有一個簡單的表單來加載用戶信息,並使其與效果一起使用,然后分派Load_User_success操作來更新商店。
我有個問題。 加載信息以填充表單具有的下拉列表並同時使用ngrx加載用戶信息的最佳方法是什么?
在組件中創建一個可觀察對象,並將其設置為等於商店中的選擇。
users$ = store.select(state => state.users);
將以下內容添加到組件定義中
@Component({changeDetection: ChangeDetectionStrategy.OnPush})
然后在模板中使用異步管道以類似以下方式處理預訂:
<div *ngIf="users$ | async">
<select>
<option *ngFor="user of (users$ | async)">{{user.name}}</option>
</select>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.