2017-11-18 22 views
0

나는 사용자의 이름으로 드롭 다운 목록을 갖고 싶다. 그러면 다중 사용자를 확인하고 선택한 사용자의 ID를 루프에 저장할 수있다. 나는 앵귤러 2 드롭 다운 멀티 시트를 사용했는데 할 수있다.multiselection 드롭 다운 각도 4

'은 t는

[https://www.npmjs.com/package/angular-2-multiple-selection]

나 API에서 중인 MyOptions 동일한 응답을 할
<select class="custom-select" [(ngModel)]="username" formControlName="username" multipe > 
    <option *ngFor="let user of users" [value]="user.user_ID"> {{ user.user_Name }} </option> 
</select> 

내가 WANY이 응답을 만들려고 안에 포장 작업 값을 변경할

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'} 
      ] 
    } 

하지만이 작동하지 않습니다 ....

+0

당신은 재료를 사용하고 있습니까? – Sajeetharan

+0

아니요, 사용하지 않았습니다 –

+0

왜이 패키지가 특별한가요? – Sajeetharan

답변

1

당신이 체크 박스와 함께 제공되지 않는 선택 일반 체크 박스와 드롭 다운을 사용하려는 때문에, 당신은 primeng 또는 각도 재료로 몇 가지 라이브러리를 이동하거나 직접해야한다 구성 요소.

각도 재료 포함 매트 선택에 복수 또는 [multiple]="true"을 추가하기 만하면됩니다.

DEMO