import { Component, OnInit, Inject } from '@angular/core'; import { MdDialog, MD_DIALOG_DATA, MdDialogRef } from '@angular/material'; import { ContactService } from '../../contact.service'; @Component({ selector: 'app-reset-password', templateUrl: './reset-password.component.html', styleUrls: ['./reset-password.component.scss'] }) export class ResetPasswordComponent implements OnInit { pass:any; cnfrmpass:any; iType:any = "password"; iType_1:any="password"; errorMsg:string; showError: boolean = false; constructor(private contactService: ContactService,public dialog: MdDialog,public dialogRef: MdDialogRef, @Inject(MD_DIALOG_DATA) public data: any) { console.log(data); } ngOnInit() { } error :boolean = false; reset(){ var that = this; let userid = this.data._id ; console.log("reset passowrd"); if(this.pass != this.cnfrmpass){ this.error = true ; that.errorMsg = "Password do not matched"; let showError = setTimeout(function(){ that.error = false; clearTimeout(showError); },3000) }else{ let payLoad={ id : userid, pass : this.pass }; this.contactService.resetPass(payLoad).subscribe(res=>{ console.log(res); this.dialogRef.close('succ'); },error=>{ console.log(error); }) } } closebox(){ console.log("close the box"); this.dialogRef.close('close'); } showBtn : boolean = true; showBtn_1 : boolean = true; show_hide_pass(id){ debugger; console.log(id); if(id == 0){ this.iType = 'text'; this.showBtn = !this.showBtn; } if(id == 1){ this.iType = 'password'; this.showBtn = !this.showBtn; } if(id == 2){ this.iType_1 = 'text'; this.showBtn_1 = !this.showBtn_1; } if(id == 3){ this.iType_1 = 'password'; this.showBtn_1 = !this.showBtn_1; } } }