Skip to main content
edited tags
Link
Andrew Eisenberg
  • 28.9k
  • 9
  • 100
  • 156
added 2 characters in body
Source Link
Dog
  • 2.9k
  • 7
  • 34
  • 72

I have a simple Angular ngForm I'm using for a put request. Because I need the id attribute to make the put request, I have attempted to add it in a hidden value. However, whenever the form is submitted the hidden id field is blank.

How can I pass in a pre-defined value to an input that will appear when the form is submitted?

I have tried multiple approaches, but nothing I have found online has worked. The hidden id field value is the one that won't appear.

The form I have is:

    <form #editForm="ngForm" (ngSubmit)="editTodoTest(editForm.value)">
      Todo<input type="text" name="description" ngModel /> UserId<input
        type="text"
        name="userId"
        ngModel
      />
      Completed<input type="text" name="completed" ngModel />
      <input type="text"type="hidden" name="id" value="10" ngModel />
      <input type="submit" />
    </form>

I have a simple Angular ngForm I'm using for a put request. Because I need the id attribute to make the put request, I have attempted to add it in a hidden value. However, whenever the form is submitted the hidden id field is blank.

How can I pass in a pre-defined value to an input that will appear when the form is submitted?

I have tried multiple approaches, but nothing I have found online has worked.

The form I have is:

    <form #editForm="ngForm" (ngSubmit)="editTodoTest(editForm.value)">
      Todo<input type="text" name="description" ngModel /> UserId<input
        type="text"
        name="userId"
        ngModel
      />
      Completed<input type="text" name="completed" ngModel />
      <input type="text" name="id" value="10" ngModel />
      <input type="submit" />
    </form>

I have a simple Angular ngForm I'm using for a put request. Because I need the id attribute to make the put request, I have attempted to add it in a hidden value. However, whenever the form is submitted the hidden id field is blank.

How can I pass in a pre-defined value to an input that will appear when the form is submitted?

I have tried multiple approaches, but nothing I have found online has worked. The hidden id field value is the one that won't appear.

The form I have is:

    <form #editForm="ngForm" (ngSubmit)="editTodoTest(editForm.value)">
      Todo<input type="text" name="description" ngModel /> UserId<input
        type="text"
        name="userId"
        ngModel
      />
      Completed<input type="text" name="completed" ngModel />
      <input type="hidden" name="id" value="10" ngModel />
      <input type="submit" />
    </form>
Source Link
Dog
  • 2.9k
  • 7
  • 34
  • 72

value attribute does not appear in Angular ngForm

I have a simple Angular ngForm I'm using for a put request. Because I need the id attribute to make the put request, I have attempted to add it in a hidden value. However, whenever the form is submitted the hidden id field is blank.

How can I pass in a pre-defined value to an input that will appear when the form is submitted?

I have tried multiple approaches, but nothing I have found online has worked.

The form I have is:

    <form #editForm="ngForm" (ngSubmit)="editTodoTest(editForm.value)">
      Todo<input type="text" name="description" ngModel /> UserId<input
        type="text"
        name="userId"
        ngModel
      />
      Completed<input type="text" name="completed" ngModel />
      <input type="text" name="id" value="10" ngModel />
      <input type="submit" />
    </form>