/
register.component.ts
44 lines (36 loc) · 1.06 KB
/
register.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Component, OnInit } from '@angular/core';
import { NgxSpinnerService } from 'ngx-spinner';
import { finalize } from 'rxjs/operators'
import { AuthService } from '../../core/authentication/auth.service';
import { UserRegistration } from '../../shared/models/user.registration';
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {
success: boolean;
error: string;
userRegistration: UserRegistration = { name: '', email: '', password: ''};
submitted: boolean = false;
constructor(private authService: AuthService, private spinner: NgxSpinnerService) {
}
ngOnInit() {
}
onSubmit() {
this.spinner.show();
this.authService.register(this.userRegistration)
.pipe(finalize(() => {
this.spinner.hide();
}))
.subscribe(
result => {
if(result) {
this.success = true;
}
},
error => {
this.error = error;
});
}
}