簡體   English   中英

為什么 Angular Material mat-horizontal-stepper 和 mat-stepper,在接下來的步驟中,首先(單擊)不起作用?

[英]Why Angular Material mat-horizontal-stepper and mat-stepper, on following step, first (click) does not work?

我的(click)事件有一個磨損問題,在 Angular 代碼中觸發了第二次點擊:

    <label class="selectLabel">Select floor tiles:</label>
    <div class="center row itemListedConainer scroller">
      <div *ngFor="let tile of getTilesFloorItems(); let i = index" class="itemListed col" 
      (click)="setTile()">
      </div>
    </div>

經過調試和多次試驗,我發現這與@angular/material/stepper有關,在進入以下步驟后,首先(click)不起作用。

我設法在這個 Stackblitz 中重現了這個問題: 鏈接

請注意,當您在step中單擊任何綠色圖塊時,您將獲得console.log('hit') ,即使是第一次。 並且在step中,第一次單擊不會登錄控制台。

這是什么原因以及如何處理?

發現問題:

更改getTilesFloorItems()模式; 將您的tiles分配給一個字段並在ngFor中從那里讀取它。 否則,您將創建 2 組tiles實例。

export class QuestionsStepperComponent {
  public setTile(): void {
    console.log('hit');
  }

  tiles: any[] = [
    {
      type: 'tiles',
   ...
<div *ngFor="let tile of tiles; ...

固定堆棧閃電戰

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM