![](/img/trans.png)
[英]Dynamically create a mat-step outside of mat-horizontal-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.