角度错误TypeError:无法读取未定义的属性'forEach'

时间:2020-01-20 18:08:42

标签: html foreach undefined

我有一个表单,下面的代码是HTML代码。该表格有2个选择菜单,我想通过单击“提交”按钮来对两个选择的选项进行细分。

<div class="form-popup playerOne" id="myForm_rsi" dir="rtl">
    <form action="/action_page.php" class="form-container" >  
      <label for="funcs"><b>  انتخاب دوره</b></label>

      <mat-select placeholder="انتخاب دوره اول" [(ngModel)] = "selectedValue1" name="rsi1">
          <mat-option *ngFor="let period of periods" [value]="period">
            {{ period }}
          </mat-option>
      </mat-select>

      <label for="funcs"><b>انتخاب دوره دوم</b></label>
      <mat-select placeholder="انتخاب دوره دوم" [(ngModel)] = "selectedValue2" name="rsi2">
        <mat-option *ngFor="let period of periods" [value]="period">
          {{ period }}
        </mat-option>
    </mat-select>

        <button type="submit" class="btn " style="margin-top: 200px;" (click)="setRsi(selectedValue1 , selectedValue2)">اعمال</button>
        <button type="button" class="btn cancel" onclick="closeForm()">انصراف</button>
    </form>
</div>

但是当我单击表单的“提交”按钮时,出现以下错误消息:

ERROR TypeError: Cannot read property 'forEach' of undefined
    at new RSI (RSI.js:42)
    at rsi (RSI.js:58)
    at FlowComponent.setRsi (flow.component.ts:372)
    at Object.eval [as handleEvent] (FlowComponent.html:52)
    at handleEvent (core.js:38098)
    at callWithDebugContext (core.js:39716)
    at Object.debugHandleEvent [as handleEvent] (core.js:39352)
    at dispatchEvent (core.js:25818)
    at core.js:37030
    at HTMLButtonElement.<anonymous> (platform-browser.js:1789)
View_FlowComponent_0 @ FlowComponent.html:52
proxyClass @ compiler.js:19436
logError @ core.js:39651
handleError @ core.js:9162
dispatchEvent @ core.js:25822
(anonymous) @ core.js:37030
(anonymous) @ platform-browser.js:1789
invokeTask @ zone-evergreen.js:391
onInvokeTask @ core.js:34182
invokeTask @ zone-evergreen.js:390
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:465
invokeTask @ zone-evergreen.js:1603
globalZoneAwareCallback @ zone-evergreen.js:1629
FlowComponent.html:52 ERROR CONTEXT DebugContext_ {view: {…}, nodeIndex: 97, nodeDef: {…}, elDef: {…}, elView: {…}}

为什么会发生,如何解决?

0 个答案:

没有答案