This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
FoodLoop-Web/src/app/pages/register.component.ts

67 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Component } from '@angular/core';
2017-05-09 13:39:48 +01:00
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { ValidationManager } from "ng2-validation-manager";
2017-04-27 22:50:11 +01:00
import { Http, Response } from '@angular/http';
2017-05-09 13:39:48 +01:00
import { ApiService } from '../providers/api-service';
2017-05-10 16:26:57 +01:00
import {Router } from '@angular/router';
2017-05-09 13:39:48 +01:00
import 'rxjs/add/operator/map';
@Component({
2017-05-09 13:39:48 +01:00
templateUrl: 'register.component.html',
providers: [ApiService]
})
export class RegisterComponent {
signup: ValidationManager;
2017-05-09 13:39:48 +01:00
ageRanges: Object[];
constructor(
private http: Http,
private formBuilder: FormBuilder,
2017-05-10 16:26:57 +01:00
private router: Router,
private api: ApiService,
) {
this.api.getAgeRanges()
.subscribe(
result => {
console.log(result);
this.ageRanges = result.ages;
}
);
this.signup = new ValidationManager({
token: 'required',
usertype: 'required',
name: 'required',
full_name: 'required',
display_name: 'required',
email: 'required',
postcode: 'required',
street_name: 'required',
town: 'required',
age_range: 'required',
password: 'required',
confirmpassword: 'required|equalTo:password'
});
2017-05-09 13:39:48 +01:00
}
onSubmit() {
console.log(this.signup.isValid());
console.log(this.signup.getForm().value);
2017-05-10 13:50:54 +01:00
/* this.api
2017-05-10 13:50:54 +01:00
.register(this.signup.value)
.subscribe(
result => {
2017-05-10 16:26:57 +01:00
console.log('registered!');
this.router.navigate(['/dashboard']);
2017-05-10 13:50:54 +01:00
},
error => {
console.log( error._body );
}
);*/
2017-04-27 22:50:11 +01:00
}
2017-05-09 13:39:48 +01:00
}