Angular ОШИБКА TypeError: Невозможно прочитать свойство 'forEach' из неопределенного - PullRequest
0 голосов
/ 20 января 2020

У меня есть форма, и следующий код - это 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: {…}}

Почему это происходит и как я могу это исправить?

...