我一直在寻找解决方案,但无法弄清楚应该如何制作。这是我几乎要寻找的内容的堆栈闪电战,但我不希望它看起来像下拉列表。 https://stackblitz.com/edit/angular-yo2o9o?file=app%2Fapp.component.html
我希望有一个像下面我自己的代码一样的列表,但在列表上实现一个搜索字段,并使用它根据输入过滤 users$ (但仍然保存所选用户)...
编辑:找到这个,https://stackblitz.com/edit/angular-i3pfu2-xgembc ?file=app%2Flist-selection-example.ts ,
这就是它应该看起来的样子,但我无法让它与我的代码一起使用。
网页:
<div class="userContainer">
<p>Choose participants</p>
<mat-selection-list class="form-group" #selectedUsers formControlName="users">
<mat-list-option *ngFor="let user of users$ | async" [value]="user">
{{ user.name }}
</mat-list-option>
</mat-selection-list>
<p>Invited users: {{ selectedUsers.selectedOptions.selected.length }}</p>
</div>
Run Code Online (Sandbox Code Playgroud)
users$ 来自我所在州的选择器
this.store$.dispatch(new fromUsers.GetUsers());
this.users$ = this.store$.pipe(select(fromUsers.getRelevantUsers(+this.userId)));
Run Code Online (Sandbox Code Playgroud)
这就是我正在使用的表格..
createEventForm() {
this.eventForm = this.fb.group(
{
users: [null],
more inside...
}
);
}
Run Code Online (Sandbox Code Playgroud)