rdt-client/client/src/app/profile/profile.component.ts

40 lines
866 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth.service';
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.scss'],
})
export class ProfileComponent implements OnInit {
constructor(private authService: AuthService) {}
public username: string;
public password: string;
public saving = false;
public success: boolean;
public error: string;
ngOnInit(): void {
}
public save(): void {
this.success = false;
this.error = null;
this.saving = true;
this.authService.update(this.username, this.password).subscribe(
() => {
this.success = true;
this.saving = false;
},
(err) => {
this.error = err.error;
this.success = false;
this.saving = false;
}
);
}
}