我的 Firebase 数据库中有一些数据,这些数据我想通过FormBuilder. 它工作得有些好,但我经常出错而不是说formGroup expects a FormGroup instance. Please pass one in.。
没有意义的是,当我对数据库应用导致订阅触发的新更改时,我收到错误消息。尽管this.settingsForm在更新后订阅运行之前和之后设置。
这是订阅:
this.eventSubscription = this.af.database.object('/events/' + this.eventId).subscribe(
(event: IEvent) => {
const rsvp: IRSVP = event.rsvp;
const settings: ISettings = event.settings;
const tickets: ITickets = event.tickets;
this.settingsForm = this.fb.group({
collaborators: this.fb.array(settings.collaborators || []),
isRSVPOpen: settings.isRSVPOpen,
isAutoApproveToGuestlist: settings.isAutoApproveToGuestlist,
rsvp: this.fb.group({
latestDate: [rsvp.latestDate, [Validators.required]],
latestTime: [rsvp.latestTime, [Validators.required]],
guestLimit: [rsvp.guestLimit, [Validators.required]],
isGuestPlusOne: rsvp.isGuestPlusOne,
isAutoApproveToGuestlist: rsvp.isAutoApproveToGuestlist,
isOnlyFacebookRSVP: rsvp.isOnlyFacebookRSVP,
isBirthdayAndPhoneRequired: rsvp.isBirthdayAndPhoneRequired
}),
tickets: this.fb.group({
info: this.fb.group({
closingDate: tickets.info.closingDate,
closingTime: tickets.info.closingTime
}),
types: this.fb.array(tickets.types || [])
})
});
}
);
所以我想知道为什么会发生这种情况,我该如何预防呢?我不能像这样初始化表格吗?