In TypeScript, I have defined the following Interface:
interface Person {
Id: number;
FirstName: string;
LastName: string;
Age: number;
}
Within a .html
partial file, there is an Angular directive ng-submit="submit()"
on a form
element. An example element inside the form looks like this:
<input id="FirstName" name="FirstName" type="text" class="form-control" ng-model="FirstName" placeholder="Enter First Name" />
I want to be able to map the form values to the object argument in the submit
call like so:
$scope.submit = (person: MyApp.Models.Person) => {
//Access person values
}
The issue arises when inspecting the person
value within the submit()
; it comes up as undefined
and not populated.
I am curious if it's feasible to automatically use and bind the multiple <input>
form values from within the form
element directly to the object argument known by TypeScript in the submit()
method?
It might be that this is simply not possible, but I would like to inquire before resorting to manually retrieving each ng-model
value and constructing a Person
instance within the submit()
function.