-import { } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
-import { AccountService } from './account.service';
-import { FormReactive, USER_PASSWORD } from '../shared';
+import { NotificationsService } from 'angular2-notifications';
+
+import { FormReactive, UserService, USER_PASSWORD } from '../shared';
@Component({
selector: 'my-account',
- template: require('./account.component.html')
+ templateUrl: './account.component.html'
})
export class AccountComponent extends FormReactive implements OnInit {
- information: string = null;
error: string = null;
form: FormGroup;
};
constructor(
- private accountService: AccountService,
private formBuilder: FormBuilder,
- private router: Router
+ private router: Router,
+ private notificationsService: NotificationsService,
+ private userService: UserService
) {
super();
}
const newPassword = this.form.value['new-password'];
const newConfirmedPassword = this.form.value['new-confirmed-password'];
- this.information = null;
this.error = null;
if (newPassword !== newConfirmedPassword) {
return;
}
- this.accountService.changePassword(newPassword).subscribe(
- ok => this.information = 'Password updated.',
+ this.userService.changePassword(newPassword).subscribe(
+ () => this.notificationsService.success('Success', 'Password updated.'),
err => this.error = err
);