0
I’m doing an Asp.Net Core Web API with Angular 7 CRUD and I’m having trouble in the final phase, just when I enter my angular localhost and open the console, I come across the following log (Note, already looked in SQL Studio Managment and the Column is created with that name)
PaymentDetailComponent.html:11 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)
View_PaymentDetailComponent_0 @ PaymentDetailComponent.html:11
Follow the codes: if necessary I edit the question by adding what more you ask.
public class PaymentDetails
{
//Propriedades do PaymentDetails
//Aparentemente usamos isso para criar um banco
//Usando alguns comandon NuGet Package Manager (Comand Line)
//Inicializaremos o banco no SQLServer Express
[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;}
}
export class PaymentDetail {
PMId: number;
CardOwner: string;
CardNumber: string;
ExpirationDate: string;
CVV: string;
}
<input name="CardOwner" #CardOwner="ngModel" [(ngModel)]="service.formData.CardOwner"
type="text" class="form-control" placeholder="CardOwner" required maxlength="100">
If I do this to take the .formData. out of the code, it works considerately. Some functions fail
<input name="CardOwner" #CardOwner="ngModel" [(ngModel)]="service.CardOwner"
type="text" class="form-control" placeholder="CardOwner" required maxlength="100">
It seems your Data form is undefined
– Eduardo Vargas
Sorry for the delay, but I set him up at the services
– Ravel Sbrissa Okada
If I take the formData, the code works, but only for insertion
– Ravel Sbrissa Okada
Best move it to component and set it onInit
– Eduardo Vargas
But in the video I’m watching the guy does exactly those steps... that makes me kind of discouraged
– Ravel Sbrissa Okada