1 import { } from '@angular/common';
2 import { Component, OnInit } from '@angular/core';
3 import { FormControl, FormGroup, Validators } from '@angular/forms';
4 import { Router } from '@angular/router';
6 import { AccountService } from './account.service';
9 selector: 'my-account',
10 template: require('./account.component.html')
13 export class AccountComponent implements OnInit {
15 newConfirmedPassword = '';
16 changePasswordForm: FormGroup;
17 information: string = null;
21 private accountService: AccountService,
22 private router: Router
26 this.changePasswordForm = new FormGroup({
27 'new-password': new FormControl('', [ <any>Validators.required, <any>Validators.minLength(6) ]),
28 'new-confirmed-password': new FormControl('', [ <any>Validators.required, <any>Validators.minLength(6) ]),
33 this.information = null;
36 if (this.newPassword !== this.newConfirmedPassword) {
37 this.error = 'The new password and the confirmed password do not correspond.';
41 this.accountService.changePassword(this.newPassword).subscribe(
42 ok => this.information = 'Password updated.',
44 err => this.error = err