国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

角度下拉列表不讀取值
P粉513316221
P粉513316221 2024-02-21 20:17:21
0
1
419

我是 Angular 的新手,所以如果我有任何錯誤,請原諒我。我正在嘗試在下拉列表中獲取創(chuàng)建的列表,當用戶選擇它時,它應該將信息記錄到數(shù)據(jù)庫中。

這是我的代碼: Component.html

<mat-form-field appearance="fill">
  <mat-label>Retrieval Reason</mat-label>
  <mat-select [formControl]="RR" required>
    <mat-option>--</mat-option>
    <mat-option *ngFor="let reason of reasons" [value]="reason">
      {{reason.reason}}
    </mat-option>
  </mat-select>
  <mat-error *ngIf="RR.hasError('required')">Please choose a reason</mat-error>
</mat-form-field>

  <button
    mat-raised-button
    (click)="done()"
    color="primary"
    [disabled]="selection.selected.length === 0 || RR.hasError('required')"
  >
    Retrieve
  </button>

Component.ts

retrievalReason: Reasons;
    RR = new FormControl('', Validators.required);

  reasons: Reasons[] = [
    {reason: 'Cycle Count'},
    {reason: 'Purge Request'},
    {reason: 'Picking'},];

    done() {
    this.dialogRef.close({
      carrier: this.carrier,
      destination: this.selection.selected[0].dstId,
      retrievalReason: this.RR.get('reasons').value,
    });
  }

我查找了從下拉列表中讀取值的 Angular 方法,并嘗試了不同的變量名稱,但到目前為止沒有任何效果。

P粉513316221
P粉513316221

全部回復(1)
P粉022723606

我認為唯一可能錯誤的是您嘗試 retrievalReason: this.RR.get('reasons').value 但這是為了獲取表單控件的表單。

您只有一個表單控件,因此只需 retrievalReason:this.RR.value 就足夠了。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板