Angular 错误类型错误:无法读取属性';名称';未定义的
当我想在表格中添加新行时,我收到此错误消息:Angular 错误类型错误:无法读取属性';名称';未定义的,angular,angular8,Angular,Angular8,当我想在表格中添加新行时,我收到此错误消息: ERROR TypeError: Cannot read property 'Nom' of undefined at Object.eval [as updateDirectives] (MedecinsComponent.html:43) at Object.debugUpdateDirectives [as updateDirectives] (core.js:36043) at checkAndUpdateView (core.j
ERROR TypeError: Cannot read property 'Nom' of undefined
at Object.eval [as updateDirectives] (MedecinsComponent.html:43)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:36043)
at checkAndUpdateView (core.js:35055)
at callViewAction (core.js:35421)
at execEmbeddedViewsAction (core.js:35378)
at checkAndUpdateView (core.js:35056)
at callViewAction (core.js:35421)
at execComponentViewsAction (core.js:35349)
at checkAndUpdateView (core.js:35062)
at callViewAction (core.js:35421)
这是我的密码:
组件。ts
this.cols=[
{字段:'User.Nom',标题:'Nom'},
{字段:'User.Prénom',标题:'Prénom'},
{字段:'User.Tel',标题:'Téléphone'},
{字段:'User.Email',标题:'Email'},
{字段:'User.Pays',标题:'Pays'},
{字段:'User.Login',标题:'Login'},
{字段:'User.Password',标题:'Password'},
{字段:'User.Active',标题:'Active'},
{字段:'Details',标题:'Détails'}
];
component.html
笔名
model.ts
从“/User”导入{User};
出口级药品{
Id:编号;
用户Id:编号;
图像:通过Telegrounk;
详细信息:字符串;
更新:日期;
创建日期:日期;
删除:日期;
用户:用户;
}
那么,是否存在实施问题?我做错了吗?因为它说“在未定义中找不到属性Nom”,所以看起来您没有对象
用户
。您必须先初始化并获取“User”实例的值。
所以在写“this.col=…”之前
尝试获取用户实例,然后将用户属性传递给对象的“col”数组。
Users
未在medecin
中定义。请共享您的组件代码。:)我很高兴