File
Implements
Metadata
selector |
crm-start-reset |
templateUrl |
./start-reset.component.html |
Methods
Private
formInit
|
formInit()
|
|
|
import {Component, OnInit} from '@angular/core';
import {FormGroup, FormBuilder, Validators} from "@angular/forms";
import {CRMValidators} from "../../shared/validators/CRMValidators";
import {AuthService} from "../../core/auth/auth.service";
import {NotificationsService} from "../../core/notifications/notifications.service";
import {Router} from "@angular/router";
@Component({
selector: 'crm-start-reset',
templateUrl: './start-reset.component.html',
styles: []
})
export class StartResetComponent implements OnInit {
startResetForm: FormGroup;
constructor(private formBuilder: FormBuilder,
private authService: AuthService,
private notificationsService: NotificationsService,
private router: Router) {
}
onSubmit() {
const email = this.startResetForm.value['email'];
console.log(email);
this.authService.startResetPassword(email).subscribe(
ok => {
this.notificationsService.success('Please, check your email for password reset instructions');
this.router.navigate(['/auth', 'signIn'])
},
error => this.notificationsService.error(error.json())
);
}
ngOnInit() {
this.formInit();
}
private formInit() {
this.startResetForm = this.formBuilder.group({
email: ['', [Validators.required, CRMValidators.email]]
})
}
}
<div class="app flex-row align-items-center">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card-group">
<div class="card p-2">
<form [formGroup]="startResetForm" (ngSubmit)="onSubmit()">
<div class="card-block">
<h1>Reset password</h1>
<p class="text-muted">Please enter your email for reset password</p>
<div class="input-group mb-1">
<span class="input-group-addon"><i class="icon-user"></i></span>
<input type="text" class="form-control" placeholder="Email" id="email" formControlName="email">
</div>
<div class="row">
<div class="col-6">
<button type="submit" class="btn btn-primary px-2" [disabled]="!startResetForm.valid">Reset</button>
</div>
<div class="col-6 text-right">
<a class="btn btn-link px-0" [routerLink]="['/auth', 'signIn']">Login</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Legend
Html element with directive