动态选择Angular Material显示状态(已检查或未选中)多项

时间:2018-04-06 14:56:49

标签: angular angular-material

我正在使用<mat-option>用于多种选择的角度素材,是否有属性可以设置 users = [{ name: 'name1', checked: true}, {name: 'name2', checked: false}, {name: 'object3', checked: true}] 来检查或不选择取决于参数的选项。 例如,如果我有3个对象:

<mat-select placeholder="users" multiple [(ngModel)]="bookform.users" name="data_scientists">
  <mat-option *ngFor="let user of users" class="mat-selected" [value]="user.id">
     <img src="http://corktrainingcentre.ie/wp-content/uploads/2015/08/person.png" class="member-picture">{{user.name}} 
  </mat-option>
</mat-select>

我想在显示我的选择时得到这个:

enter image description here

{{1}}

1 个答案:

答案 0 :(得分:2)

你想做的事情本身并不完全支持,但你可以用这样的东西来实现它:

Working demo