Guest User

Untitled

a guest
Feb 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import { Component, Input } from '@angular/core';
  2. import { FormGroup } from '@angular/forms';
  3.  
  4. @Component({
  5. selector: 'app-child',
  6. template: `
  7. <h1>Enter your name</h1>
  8. <form
  9. [formGroup]="nameForm"
  10. (ngSubmit)="submitForm(nameForm)"
  11. >
  12. <input
  13. type="text"
  14. formControlName="firstName"
  15. placeholder="first"
  16. >
  17. <input
  18. type="text"
  19. formControlName="lastName"
  20. placeholder="last"
  21. >
  22. <button type="submit">launch to space</button>
  23. </form>
  24. `,
  25. styleUrls: ['./child.component.css']
  26. })
  27. export class ChildComponent {
  28. @Input() nameForm: FormGroup;
  29.  
  30. submitForm(form: FormGroup) {
  31. console.log(form);
  32. // really you would be using an event emitter
  33. }
  34. }
Add Comment
Please, Sign In to add comment