【发布时间】:2020-06-15 21:27:22
【问题描述】:
我正在使用基于组件的 mat stepper 组件来显示线性过程。每个步骤都有自己的组件,如下所示
<mat-card>
<mat-horizontal-stepper [linear]="isLinear" labelPosition="bottom" #stepper>
<!-- Step-1 -->
<mat-step [stepControl]="firstFormGroup">
<ng-template matStepLabel>Select Items</ng-template>
<select-item-component>
<select-item-component>
<div class="mt-5">
<button mat-flat-button color="primary" matStepperNext>Next</button>
</div>
</mat-step>
<!-- Step-2 -->
<mat-step [stepControl]="firstFormGroup">
<ng-template matStepLabel>Add Quantity</ng-template>
<add-qty-component>
<add-qty-component>
<div class="mt-5">
<button mat-flat-button color="primary" matStepperNext>Next</button>
</div>
</mat-step>
<!-- Step-3 -->
<mat-step [stepControl]="firstFormGroup">
<ng-template matStepLabel>Conform</ng-template>
<conform-step-component>
<conform-step-component>
<div class="mt-5">
<button mat-flat-button color="primary" matStepperNext>Done</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-card>
Step-1 显示可多选的项目列表,并将选定的项目列表传递到下一个 step-2,并在 step-2 中添加每个项目的数量。
如何在 Next click 从 step-1 到 step-2 传递选定的项目并显示传递的项目以在 step-2 中输入数量?
我创建了一个通用服务层来设置和获取选定的项目。 ngOnInit 的步骤 2 的组件试图从公共服务中获取所选列表,但问题是组件 2 在下次单击之前已启动。
第1步点击next后可以初始化或重新初始化第二个组件吗?
从步骤 1 移动后如何显示步骤 2 中的选定项目列表?
上述场景的最佳方法是什么?
只要一个可以回答我问题的参考资料的链接就足够了。
谢谢。
【问题讨论】:
-
您还在寻找解决方案还是找到了??
标签: javascript angular components mat-stepper