Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Component({
- selector: 'app-parent-form',
- templateUrl: './parent-form.component.html',
- styleUrls: ['./parent-form.component.scss'],
- changeDetection: ChangeDetectionStrategy.OnPush
- })
- export class ParentFormComponent implements OnInit {
- _parentForm: ParentForm;
- @Input()
- set parentForm(value: ParentForm) {
- this._parentForm = value;
- this.formUtilsService.setValues(this.fg, value);
- this.formStatus = '';
- this.formValue = '';
- }
- @Output()
- result = new EventEmitter<ParentForm>();
- fg: FormGroup;
- formStatus = '';
- formValue = '';
- constructor(private fb: FormBuilder, private formUtilsService: FormUtilsService) {
- this.fg = this.fb.group({});
- }
- ngOnInit() {}
- submit() {
- this.formUtilsService.validate(this.fg);
- this.formStatus = this.fg.valid ? 'VALID' : 'INVALID';
- this.formValue = JSON.stringify(this.fg.value);
- if (this.fg.valid) {
- this.result.emit({ ...this.fg.value } as ParentForm);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement