SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Component({
  2.   selector: 'app-parent-form',
  3.   templateUrl: './parent-form.component.html',
  4.   styleUrls: ['./parent-form.component.scss'],
  5.   changeDetection: ChangeDetectionStrategy.OnPush
  6. })
  7. export class ParentFormComponent implements OnInit {
  8.   _parentForm: ParentForm;
  9.   @Input()
  10.   set parentForm(value: ParentForm) {
  11.     this._parentForm = value;
  12.     this.formUtilsService.setValues(this.fg, value);
  13.     this.formStatus = '';
  14.     this.formValue = '';
  15.   }
  16.  
  17.   @Output()
  18.   result = new EventEmitter<ParentForm>();
  19.  
  20.   fg: FormGroup;
  21.  
  22.   formStatus = '';
  23.   formValue = '';
  24.  
  25.   constructor(private fb: FormBuilder, private formUtilsService: FormUtilsService) {
  26.     this.fg = this.fb.group({});
  27.   }
  28.  
  29.   ngOnInit() {}
  30.  
  31.   submit() {
  32.     this.formUtilsService.validate(this.fg);
  33.     this.formStatus = this.fg.valid ? 'VALID' : 'INVALID';
  34.     this.formValue = JSON.stringify(this.fg.value);
  35.     if (this.fg.valid) {
  36.       this.result.emit({ ...this.fg.value } as ParentForm);
  37.     }
  38.   }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top