Skip to content

Instantly share code, notes, and snippets.

@openopen114
Created May 5, 2017 06:07
Show Gist options
  • Select an option

  • Save openopen114/6952c6a23137fbb50c39581f62758d9d to your computer and use it in GitHub Desktop.

Select an option

Save openopen114/6952c6a23137fbb50c39581f62758d9d to your computer and use it in GitHub Desktop.
// in html
<form #userform = "ngForm" (ngSubmit) = "onSubmit(userform.value)">
<input name="first" ngModel required #first="ngModel">
<input type="text" placeholder="lastname" name="lastname" ngModel>
<select name="lang" ngModel>
<option value="a1">a1</option>
<option value="a2">a2</option>
<option value="a3">a3</option>
</select>
<input type="submit" value="submit">
</form>
<p>First name value: {{ first.value }}</p>
// in module.ts
onSubmit = function(user){
console.log(user);
console.log(user.first);
console.log(user.lastname);
console.log(user.lang);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment