2018-04-06 06:59:49 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { Router } from '@angular/router';
|
2018-04-10 07:30:05 +00:00
|
|
|
import { FormGroup, FormBuilder, Validators, AbstractControl } from '@angular/forms';
|
|
|
|
import { Member } from '@loafer/core/reflect';
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-member-signup',
|
|
|
|
templateUrl: './signup.component.html',
|
|
|
|
styleUrls: ['./signup.component.scss']
|
|
|
|
})
|
|
|
|
export class SignupComponent implements OnInit {
|
|
|
|
|
|
|
|
signupForm: FormGroup;
|
|
|
|
formErrors = {
|
|
|
|
'email': '',
|
|
|
|
'password': '',
|
|
|
|
'pwConfirm': '',
|
|
|
|
'name': '',
|
|
|
|
'phone': '',
|
|
|
|
'company': ''
|
|
|
|
};
|
2018-04-10 07:30:05 +00:00
|
|
|
member: Member;
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private router: Router,
|
|
|
|
private formBuilder: FormBuilder
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.initForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
initForm() {
|
|
|
|
this.signupForm = this.formBuilder.group({
|
|
|
|
'email': ['', [
|
|
|
|
Validators.required,
|
|
|
|
Validators.email
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'password': ['', [
|
2018-04-10 07:30:05 +00:00
|
|
|
Validators.required,
|
2018-04-06 06:59:49 +00:00
|
|
|
Validators.pattern('^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$'),
|
|
|
|
Validators.minLength(6),
|
2018-04-10 07:30:05 +00:00
|
|
|
Validators.maxLength(25),
|
2018-04-06 06:59:49 +00:00
|
|
|
]
|
|
|
|
],
|
|
|
|
'pwConfirm': ['', [
|
2018-04-10 07:30:05 +00:00
|
|
|
Validators.required,
|
2018-04-06 06:59:49 +00:00
|
|
|
]
|
|
|
|
],
|
|
|
|
'name': ['', [
|
|
|
|
Validators.required
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'phone': ['', [
|
|
|
|
Validators.required
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'company': ['', [
|
|
|
|
Validators.required
|
|
|
|
]
|
|
|
|
],
|
2018-04-10 07:30:05 +00:00
|
|
|
}, this.pwdMatchValidator);
|
|
|
|
}
|
|
|
|
|
|
|
|
pwdMatchValidator(frm: FormGroup) {
|
|
|
|
return frm.get('password').value === frm.get('pwConfirm').value
|
|
|
|
? null : {'mismatch': true};
|
|
|
|
}
|
2018-04-06 06:59:49 +00:00
|
|
|
|
2018-04-10 07:30:05 +00:00
|
|
|
signup() {
|
|
|
|
const signinValue = Object.assign({}, this.signupForm.value);
|
|
|
|
console.log(signinValue);
|
2018-04-06 06:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|