Skip to main content
1 of 3
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>
Dog
  • 2.9k
  • 7
  • 34
  • 72