Привет.
Подскажите, как сделать подтверждение пароля?
Есть html-файл с формой, и компонент для регистрации.
Как сделать проверку на идентичность Password i confirmPassword?
<div class="form-group" [ngClass]="{ 'has-error': f.submitted && !password.valid }">
<label for="password">Password</label>
<input type="password" class="form-control" name="password" [(ngModel)]="model.password" #password="ngModel" required />
<div *ngIf="f.submitted && !password.valid" class="help-block">Password is required</div>
</div>
<div class="form-group" [ngClass]="{ 'has-error': f.submitted && !repassword.valid }">
<label for="repassword">RePassword</label>
<input type="repassword" class="form-control" name="repassword" [(ngModel)]="model.repassword" #repassword="ngModel" />
<div *ngIf="f.submitted || repassword.valid===repassword.valid" class="help-block">rePassword is required</div>
</div>
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AlertService, UserService } from '../_services/index';
@Component({
moduleId: module.id,
templateUrl: 'register.component.html'
})
export class RegisterComponent {
model: any = {};
loading = false;
constructor(
private router: Router,
private userService: UserService,
private alertService: AlertService) { }
register() {
this.loading = true;
this.userService.create(this.model)
.subscribe(
data => {
// set success message and pass true paramater to persist the message after redirecting to the login page
this.alertService.success('Registration successful', true);
this.router.navigate(['/login']);
},
error => {
this.alertService.error(error);
this.loading = false;
});
}
}
Как сделать проверку на идентичность Password i confirmPassword?