我正在使用Asp.Net Core Web API和Angular 7 CRUD进行练习,但是在输入接收到该属性时遇到了一些麻烦。
我已经检查了数据库列,并且名称没有错。并检查了服务。
<input name="CardOwner" #CardOwner="ngModel"[(ngModel)]="service.formData.CardOwner"
type="text" class="form-control" placeholder="CardOwner" required maxlength="100">
export class PaymentDetail {
PMId: number= 0;
CardOwner: string= "";
CardNumber: string= "";
ExpirationDate: string= "";
CVV: string= "";
}
public class PaymentDetails
{
[Key]
public int PMId { get; set; }
[Required]
[Column(TypeName ="nvarchar(100)")]
public String CardOwner { get; set; }
[Required]
[Column(TypeName = "nvarchar(16)")]
public String CardNumber { get; set; }
[Required]
[Column(TypeName = "nvarchar(5)")]
public String ExpirationDate { get; set; }
[Required]
[Column(TypeName = "nvarchar(3)")]
public String CVV { get; set;}
}
ERROR TypeError: Cannot read property 'CardOwner' of undefined
at Object.eval [as updateDirectives] (PaymentDetailComponent.html:11)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:23911)
at checkAndUpdateView (core.js:23307)
at callViewAction (core.js:23548)
at execComponentViewsAction (core.js:23490)
at checkAndUpdateView (core.js:23313)
at callViewAction (core.js:23548)
at execComponentViewsAction (core.js:23490)
at checkAndUpdateView (core.js:23313)
at callViewAction (core.js:23548)