Created
January 31, 2021 12:45
-
-
Save Teebo/8d29cf990507d120144affce50526914 to your computer and use it in GitHub Desktop.
HobbiesComponent - Uses ControlContainer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input, OnInit } from '@angular/core'; | |
import { ControlContainer, FormGroup } from '@angular/forms'; | |
@Component({ | |
selector: 'app-hobbies', | |
templateUrl: './hobbies.component.html', | |
styleUrls: ['./hobbies.component.scss'] | |
}) | |
export class HobbiesComponent implements OnInit { | |
public hobbiesForm: FormGroup; | |
@Input() parentForm: FormGroup; | |
constructor(private controlContainer: ControlContainer) { } | |
public ngOnInit(): void { | |
this.hobbiesForm = this.controlContainer.control as FormGroup; | |
} | |
public logForms(): void { | |
console.log('Hobbies form', this.hobbiesForm); | |
console.log('Parent (Hero) form', this.parentForm); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment