Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. The NgModelGroup directive
  2.  
  3. We can group the form controls into the control group. The form itself is a control group. It is possible to track the validity state of the controls in the group. Like the control uses a ngModel directive, the group utilizes a NgModelGroup directive:
  4.  
  5. <form #myForm="ngForm" (ngSubmit)="handle(myForm.value)">
  6. <fieldset ngModelGroup="user">
  7. <label>User Name:</label>
  8. <input type="text" name="name" ngModel>
  9. <label>Password:</label>
  10. <input type="password" name="password" ngModel>
  11. </fieldset>
  12. <fieldset ngModelGroup="contact">
  13. <label>Phone:</label>
  14. <input type="text" name="phone" ngModel>
  15. <label>Email:</label>
  16. <input type="email" name="email" ngModel>
  17. </fieldset>
  18. <button type="submit">Submit</button>
  19. </form>
  20. We can use fieldset or div elements to group controls. With the help of ngModelGroup, we semantically group controls into user and contact information:
  21.  
  22. {
  23. user: {
  24. name: 'User',
  25. password: 'myPassword'
  26. },
  27. contact: {
  28. phone: '000-111-22-33',
  29. email: 'test@test.com'
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement