Skip to content

Instantly share code, notes, and snippets.

@kseniya292
Created March 21, 2018 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kseniya292/c62e3874398e0bbb3a773a04b0f6c6d6 to your computer and use it in GitHub Desktop.
Save kseniya292/c62e3874398e0bbb3a773a04b0f6c6d6 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { ProgressService } from '../progress.service';
import { PatientService } from '../../patient.service';
@Component({
selector: 'app-patient-info',
templateUrl: './patient-info.component.html',
styleUrls: ['./patient-info.component.css']
})
export class PatientInfoComponent implements OnInit {
patientForm: FormGroup;
submitted: Boolean;
constructor (
private fb: FormBuilder,
private _patientService: PatientService,
private _router: Router,
private _route: ActivatedRoute,
private _progressService: ProgressService,
) {
this.createForm();
this.submitted = false;
}
onSubmit(data: FormGroup) {
this.submitted = true;
this._patientService.setPatientForm(data);
this._patientService.postPatient(data)
.subscribe(
res => this._router.navigate(['../scheduling'], { relativeTo: this._route}),
err => console.log(err)
);
}
ngOnInit() {
this._progressService.setProgress(50);
}
createForm() {
this.patientForm = this.fb.group({
first: ['', Validators.required ],
last: ['', Validators.required ],
location: this.fb.group({
address: ['', Validators.required ],
address2: '',
city: ['', Validators.required ],
state: ['', Validators.required ],
postcode: ['', Validators.required ],
}),
dob: ['', Validators.required ],
email: '',
phone: ['', Validators.required ],
provider: ['', Validators.required ],
why: ['', Validators.required ]
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment