1 import { Component, OnInit } from '@angular/core'
2 import { FormBuilder, FormGroup, Validators } from '@angular/forms'
3 import { Router } from '@angular/router'
5 import { NotificationsService } from 'angular2-notifications'
7 import { AuthService } from '../core'
15 import { UserCreate } from '../../../../shared'
18 selector: 'my-signup',
19 templateUrl: './signup.component.html'
21 export class SignupComponent extends FormReactive implements OnInit {
30 validationMessages = {
31 'username': USER_USERNAME.MESSAGES,
32 'email': USER_EMAIL.MESSAGES,
33 'password': USER_PASSWORD.MESSAGES
37 private formBuilder: FormBuilder,
38 private router: Router,
39 private notificationsService: NotificationsService,
40 private userService: UserService
46 this.form = this.formBuilder.group({
47 username: [ '', USER_USERNAME.VALIDATORS ],
48 email: [ '', USER_EMAIL.VALIDATORS ],
49 password: [ '', USER_PASSWORD.VALIDATORS ]
52 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
62 const userCreate: UserCreate = this.form.value
64 this.userService.signup(userCreate).subscribe(
66 this.notificationsService.success('Success', `Registration for ${userCreate.username} complete.`)
67 this.router.navigate([ '/videos/list' ])
70 err => this.error = err.text