Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, Input } from '@angular/core';
- import { FormGroup } from '@angular/forms';
- @Component({
- selector: 'app-child',
- template: `
- <h1>Enter your name</h1>
- <form
- [formGroup]="nameForm"
- (ngSubmit)="submitForm(nameForm)"
- >
- <input
- type="text"
- formControlName="firstName"
- placeholder="first"
- >
- <input
- type="text"
- formControlName="lastName"
- placeholder="last"
- >
- <button type="submit">launch to space</button>
- </form>
- `,
- styleUrls: ['./child.component.css']
- })
- export class ChildComponent {
- @Input() nameForm: FormGroup;
- submitForm(form: FormGroup) {
- console.log(form);
- // really you would be using an event emitter
- }
- }
Add Comment
Please, Sign In to add comment