заполнить mat-select (ngModel) программно - PullRequest
0 голосов
/ 15 января 2020

Я хочу заполнить коврик программно без использования formGroup. Я нашел только решения с formGroups. Но вы не можете использовать "ngForm" amd formGroup вместе.

<form #filterForm="ngForm" appIdentityRevealed>
  <mat-form-field>
    <mat-select name="selectReports" [(ngModel)]="reportIds" multiple>
      <mat-option *ngFor="let report of filterReport" [value]="report.databaseId">
        {{report.Name}}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <button mat-raised-button type="button" (click)="markAllReports()">
              Alle Berichte auswählen
            </button>
  <div class="space-top ">
    <button type="submit " color="primary " mat-raised-button (click)="submit ">---</button>
  </div>
</form>

Когда я добавляю идентификаторы в отчет отчета массива, выбор циновки не обновляет / не обновляет sh.

Мой код добавить идентификаторы:

markAllReports() {
  this.allReports.map(x => x.reportTyp ? this.reportIds.push(x.databaseId) : null)
}

1 Ответ

1 голос
/ 15 января 2020
markAllReports() {
  tempArray:any=[];
  this.allReports.map(x => x.reportTyp ? tempArray.push(x.databaseId) :  null);
  this.reportIds=tempArray
 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...