angular - 推送记录到课堂
问题描述
我有一个定义如下的类:
export class Children {
relationship: string;
firstname: string;
middlename: string;
lastname: string;
gender: string;
dob: string;
ssn: string;
phone: string;
email: string;
address1: string;
address2: string;
city: string;
state: string;
zip: string;
disabled: string;
}
我将其导入到我的 .ts 文件中。
另外,我已将其初始化如下:
public children: Children[]=[];
但是在尝试添加记录时,我收到错误 TypeError: undefined is not an object (evalating 'child.relationship = this.chrelationship')
这是我用来推送记录的代码:
SaveChildren(): void {
let child: Children;
child.relationship=this.chrelationship;
child.firstname=this.chfirstname;
child.lastname=this.chlastname;
child.middlename=this.chmiddlename;
child.gender=this.chgender;
child.dob=this.chdob;
child.ssn=this.chssn;
child.phone=this.chphone;
child.email=this.chemail;
child.address1=this.chaddress;
child.address2=this.chaddress2;
child.city=this.chcity;
child.state=this.chstate;
child.zip=this.chzip;
child.disabled=this.chdisabled;
this.children.push(child);
console.log(this.children)
}
我无法弄清楚我做错了什么......
解决方案
推荐阅读
- java - 如何在其他活动中使用最终变量?
- angular - 角度绑定无法正常工作
- python - 在 Windows 10 上的 python 进程中导入 tensorflow 需要 1.5GB 的 RAM
- android - 如何将领域对象从后台线程传递给 UiThread?
- java - spring boot thymeleaf 多选数据绑定 mongodb
- react-native - react-native expo 问题:`SceneView` 的检查方法
- regex - 使用 sed 在特定文本之后删除文件名中的空格
- python - 单应性透视投影不起作用
- java - 如何将一个rdd拆分成多个rdd(横向),GC开销异常
- java - Java 集的并集或交集