profile.component.ts 1.04 KB
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';


const new_password = new FormControl('', Validators.required);
const confirm_password = new FormControl('', CustomValidators.equalTo(new_password));

@Component({
  selector: 'app-profile',
  templateUrl: './profile.component.html',
  styleUrls: ['./profile.component.scss']
})
export class ProfileComponent implements OnInit {

  public form: FormGroup;
  selectedRole = 'SUPERADMIN';

  constructor(public dialogRef: MatDialogRef<ProfileComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any, private fb: FormBuilder) {
     }

  ngOnInit() {
    this.form = this.fb.group({
      uname: [null, Validators.compose([Validators.required])],
      old_password: [null, Validators.compose([Validators.required])],
      new_password: new_password,
      confirm_password: confirm_password
    });

  }

}