我正在做一個 angular 11 專案。
提交表單時出現此錯誤。
ERROR TypeError: Cannot read property 'reset' of undefined at SafeSubscriber.settingsService.create.subscribe.loading [as _next]
我的組件.ts
import { NbStepperComponent} from '@nebular/theme';
@ViewChild('settingFormStepper') settingFormStepper: NbStepperComponent;
this.settingsService.create(formData)
.subscribe((settings) => {
this.toastrService.show(' Settings added', { status: 'success', duration: 10000 });
this.settingsService.resetForm();
this.settingFormStepper.reset(); // error on this this line
}
.html 檔案
<nb-card-body *ngIf="!loading" >
<form [formGroup]="sitesettingForm">
<nb-stepper #settingFormStepper [disableStepNavigation]="true" orientation="horizontal">
<nb-step> </nb-step>
</nb-stepper>
</form>
</nb-card-body>
我犯了什么錯誤?
uj5u.com熱心網友回復:
看起來就像<nb-stepper>當你正試圖呼叫沒有呈現reset()。所以,this.settingFormStepper是undefined。你能提供整個 HTML 模板嗎?或者,你有沒有*ngIf把<nb-stepper>它包起來?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/334779.html
標籤:有角的
上一篇:如何使用Angular8中的反應形式將資料與單獨的標頭系結
下一篇:帶有Angular組件的Chart.js-型別'string'不可分配給型別'ChartTitleOptions|不明確的'
