Created
March 21, 2018 15:41
-
-
Save kseniya292/c62e3874398e0bbb3a773a04b0f6c6d6 to your computer and use it in GitHub Desktop.
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, 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