How to mask and unmask input element password type in ionic/angular/js:
this.togglePasswordField = function () {
console.log("toggle password field called");
if (document.getElementById("passwordElement").type == "password") {
document.getElementById("passwordElement").type = "text";
document.getElementById("passwordHideIcon").classList.remove("ion-eye");
document.getElementById("passwordHideIcon").classList.add("ion-eye-disabled");
}
else {
document.getElementById("passwordElement").type = "password";
document.getElementById("passwordHideIcon").classList.remove("ion-eye-disabled");
document.getElementById("passwordHideIcon").classList.add("ion-eye");
}
}
This way only uses basic html element manipulation.
passwordHideIcon element is a button that calls the function and uses the ionic icon for eyes and eyes disabled.
