相关疑难解决方法(0)

预选多个值以进行垫选择-Angular 6

我试图在垫选择中预选多个选项。到目前为止,我还无法实现这一目标。

这是HTML文件:

<mat-dialog-content [formGroup]="form">
   <mat-form-field>
     <mat-select placeholder="participants" formControlName="participants"  multiple>
         <mat-option *ngFor="let participant of participants" [value]="participant">{{participant}}</mat-option>
     </mat-select>
    </mat-form-field>
</mat-dialog-content>
Run Code Online (Sandbox Code Playgroud)

这是控制器:

export class EventViewModalComponent implements OnInit {
  form: FormGroup;
  calendarEvent: CalendarEvent;
  participants = [];

  constructor(private fb: FormBuilder,
    private participantService: ParticipantService,
    @Inject(MAT_DIALOG_DATA) event: CalendarEvent) 
    { 
    this.form = fb.group({
      title: [event.title, Validators.required],
      location: [event.meta.location, Validators.required],
      description: [event.meta.description, Validators.required],
      start: [event.start, Validators.required],
      end: [event.end, Validators.required],
      participants: [this.participants, Validators.required]
    });
    this.calendarEvent = event;
  }

  ngOnInit() {
    this.participantService.getAll().subscribe(data =>{
      for(let i = 0; i < data['length']; i++){ …
Run Code Online (Sandbox Code Playgroud)

html typescript angular-material angular

6
推荐指数
2
解决办法
5437
查看次数

标签 统计

angular ×1

angular-material ×1

html ×1

typescript ×1