import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; import { FormBuilder, Validators } from '@angular/forms'; import { AuthenticationService } from '../../Config/services/auth.service'; import { ValidationService} from '../../Config/services/validation.service'; import {StorageService } from '../../Config/services/storage.service'; @Component({ selector: 'app-changepassword', templateUrl: './changepassword.page.html', styleUrls: ['./changepassword.page.scss'], }) export class ChangepasswordPage implements OnInit { userData: any; passwordForm = this.fb.group({ user_id: ['', Validators.required], password: ['', Validators.compose([Validators.required, Validators.minLength(6)])], newpassword: ['', Validators.compose([Validators.required, Validators.minLength(6)])] }); constructor( private router: Router, private validationService: ValidationService, private authenticationService: AuthenticationService, private route: ActivatedRoute, private location: Location, private fb: FormBuilder, private storageservice: StorageService ) { } ngOnInit() { } goToPage(path, data= null) { this.router.navigateByUrl(path, {queryParams: data}); document.body.scrollTop = document.documentElement.scrollTop = 0; } goBack() { this.location.back(); } getStorageData() { this.userData = JSON.parse(this.storageservice.getLocalStorageItem('userData')); } changePsw() { this.passwordForm.patchValue({ user_id : this.userData.profile_id }); if (this.passwordForm.valid) { if (this.passwordForm.value.password === this.passwordForm.value.newpassword) { } else { this.validationService.presentToast('Password Mismatch!'); this.passwordForm.reset(); document.body.scrollTop = document.documentElement.scrollTop = 0; } } else { this.validationService.presentToast('Please enter all fields'); this.passwordForm.reset(); document.body.scrollTop = document.documentElement.scrollTop = 0; } } }