我想在表中添加新行时收到此错误消息:
=============
INPUT EXAMPLE
=============
text = "Cat 01-08-2019 16:32\r\nDog 03-08-2019 12:32\r\nBear 13-07-2019 19:22"
nameFile = "Dog"
===============
EXPECTED OUTPUT
===============
lastRun = "03-08-2019 12:32"
这是我的代码:
component.ts
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)
component.html
this.cols = [
{ field: 'User.Nom', header: 'Nom' },
{ field: 'User.Prénom', header: 'Prénom' },
{ field: 'User.Tel', header: 'Téléphone' },
{ field: 'User.Email', header: 'Email' },
{ field: 'User.Pays', header: 'Pays' },
{ field: 'User.Login', header: 'Login' },
{ field: 'User.Password', header: 'Password' },
{ field: 'User.Active', header: 'Active' },
{ field: 'Details', header: 'Détails'}
];
model.ts
<p-dialog header="Détails de l'utilisateur" [(visible)]="displayDialog" [responsive]="true" showEffect="fade" [modal]="true" [closable]="true" [width]="600">
<div class="ui-g ui-fluid" *ngIf="medecin">
<div class="ui-g-4"><label for="Nom">Nom</label></div>
<div class="ui-g-8"><input pInputText id="Nom" [(ngModel)]="medecin.Users.Nom"/></div>
</div>
</p-dialog>
那么,有实施上的问题吗?我做错了吗?
答案 0 :(得分:1)
您必须首先初始化并获取“ User”实例的值。 所以在写“ this.col = ...”之前 尝试获取用户实例,然后将用户属性传递给“ col”对象数组。
答案 1 :(得分:0)
因为它说“找不到未定义的Nom属性”,所以看来您没有对象User
开始。