Try to search your question here, if you can't find : Ask Any Question Now ?

Angular form doesn't return binded object

HomeCategory: stackoverflowAngular form doesn't return binded object
Avatarjohn asked 2 weeks ago

I’m trying to create an angular form with 2 input fields that upon submission posts the values of the fields to a function that handles them accordingly

I’ve made sure that the FormsModule and NgForm are imported correctly

  <div class="modal-body">

    <form class="example-form" (submit)="createNewPartySubmit(newPartyForm)" #newPartyForm="ngForm">
      <mat-form-field class="input-field" floatLabel="auto">
        <input matInput name="name" type="text" [ngModel]="newPartyItem?.name" required #name="ngModel" />

      <mat-form-field class="input-field" floatLabel="auto">
        <input matInput name="country" type="text" [ngModel]="newPartyItem?.country" required #country="ngModel" />
      <div class="modal-footer">
        <button mat-button type="submit" class="btn btn-primary primary" (click)="createNewPartySubmit()">Submit</button>

and the function handling is as below

  createNewPartySubmit(newPartyForm: NgForm) {

the printed output is undefined

1 Answers
Best Answer
AvatarMatthias answered 2 weeks ago
Your Answer

8 + 7 =

Popular Tags

WP Facebook Auto Publish Powered By :