Cannot read Property 'Name"' of Undefined at Object.Val [as updateDirectives]

Asked

Viewed 696 times

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

  • Sorry for the delay, but I set him up at the services

  • If I take the formData, the code works, but only for insertion

  • Best move it to component and set it onInit

  • But in the video I’m watching the guy does exactly those steps... that makes me kind of discouraged

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.