码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular2 Form] Group Inputs in Angular 2 Forms with ngModelGroup

时间:2016-09-27 19:39:44      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

The ngModelGroup directive allows you to group together related inputs so that you structure the object represented by the form in a useful and predictable way. ngModelGroup is often used in combination with fieldset as they mostly represent the same idea of “grouping together inputs.”

 

  <form name="myForm2" #formRef2="ngForm" (ngSubmit)="onSubmit(formRef2.value)">
    <fieldset ngModelGroup="login">
      <legend>Login:</legend>

      Username: <input type="text" name="username" ngModel required>
      Password: <input type="password" name="password" ngModel requried>

    </fieldset>
  </form>
  <pre>
    form value: {{formRef2.value | json}}
    form valid: {{formRef2.valid | json}}
  </pre>

 

Github

[Angular2 Form] Group Inputs in Angular 2 Forms with ngModelGroup

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5913909.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!