gpt4 book ai didi

angular2 react 形式 |未捕获的类型错误 : Cannot set property stack of [object Object] which has only a getter

转载 作者:太空狗 更新时间:2023-10-29 17:33:12 25 4
gpt4 key购买 nike

我正在尝试实现一个 angular2 响应式表单,但在加载组件时出现运行时错误

未捕获的类型错误:无法设置只有 getter 的 [object Object] 的属性堆栈

这个错误不是很清楚,所以我很难弄清楚发生了什么。我正在关注 angular university article .我认为可能有重大更改,所以我检查了 angular2 更改日志,但没有发现任何与我的响应式表单问题相关的内容。

如有任何帮助,我们将不胜感激。我将继续寻找解决方案。

addevent.component.ts

@Component({
selector: 'addevent',
templateUrl: 'addevent.component.html',
styleUrls: ['addevent.scss']
})
export class AddEvent {

// vars
private _addEventForm:FormGroup;
private _eventTitle:FormControl;
private _eventDescription:FormControl;

constructor(private _addEventService:AddEventService,
private _formBuilder:FormBuilder) {
// init vars
this. _eventTitle = new FormControl('', Validators.required);
this._eventDescription = new FormControl('', Validators.required);
this._addEventForm = _formBuilder.group({
'eventTitle': this._eventTitle,
'eventDescription': this._eventDescription
});
}

private addEvent():void {
console.log(this._addEventForm);
//this._addEventService.addEvent();
}

}

addevent.component.html

<div class="h3 content-title">Add Event</div>

<form [formGroup]="_addEventForm" (ngSubmit)="addEvent()">
<p>
<label>Title</label>
<input type="text" formControlName="eventTitle">
</p>
<p>
<label>Description</label>
<input type="text" formControlName="eventDescription">
</p>
<p>
<button type="submit" [disabled]="_addEventForm.invalid">Submit</button>
</p>
</form>

dashboard.module.ts

@NgModule({
declarations: [Dashboard, Navbar, Sidebar, Home, Profile, Events, AddEvent],
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule],
providers: [ContentSwap, SidebarActivity, AuthService, FirebaseAuthService]
})
export class DashboardModule {}

最佳答案

我有时会遇到同样的错误。看起来像是最新的 zonejs/angular 中的错误。要获得真正的错误,请在抛出此错误的堆栈上放置一个断点。您真正的错误将是它崩溃的函数的输入参数。

如果您需要更多详细信息 https://github.com/angular/zone.js/issues/427

关于angular2 react 形式 |未捕获的类型错误 : Cannot set property stack of [object Object] which has only a getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39398910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com