我想达到什么:传递变量从ngFor到组件的方法
每当用户选择在上选在下面的代码中的一些选项,我要与所选择的对象来执行该组件的方法onSelectSampleType作为将组件的某些公共属性设置为传递参数的参数。
<select (change)="onSelectSampleType(SampleType)">
<option *ngFor="let SampleType of sampleTypeList">{{ SampleType }}</option>
</select>
<select *ngIf="selectedSample"">
<option *ngFor ="let subType of selectedSampleType.subType">{{ subType }}</option>
</select>
问题: 在onSelectSampleType的SampleType参数()方法,它被认为捕获ngFor指令SampleType被捕捉什么和通过未定义的值。我认为ngfor指令中的SampleType变量的范围仅限于标记。
有什么办法可以完成我想要达到的目标吗?
SampleType'的范围''是
我想我很难理解这一点。我该如何解决这个问题? –