【发布时间】:2017-11-18 12:39:27
【问题描述】:
我想要一个带有用户名的下拉列表,然后我可以检查多个用户并将所选用户的 ID 保存在数组中以循环它们.. 我使用 angular-2-dropdown-multiselect 但我无法更改其中的价值观 [https://www.npmjs.com/package/angular-2-multiple-selection]
<select class="custom-select" [(ngModel)]="username" formControlName="username" multipe >
<option *ngFor="let user of users" [value]="user.user_ID"> {{ user.user_Name }} </option>
</select>
我想让 myOptions 来自 API 的同等响应
我试图在包工作的时候做出这个响应:
this.dataStorageService.getUsers().subscribe(response => {
this.users= response.json() ;
});
for(let i = 0 ; i < this.users.length; i++){
this.test= this.users[i].user_Name;
this.testId = this.users[i].user_ID;
this.myOptions=[
{ id : this.testId , name: 'this.test'}
]
}
但它不起作用....
【问题讨论】:
-
为什么特别是这个包?
-
在我的情况下如何使用复选框,因为我有很多用户
-
这个包依赖于 Bootstrap CSS 3 或 4 github.com/softsimon/angular-2-dropdown-multiselect
标签: angular api typescript multi-select