How to validate ng-blur using Bootstrap & angular - angularjs

Here I am using ng-blur for checking if email exits or not.It is working as I expected but why it's not getting validated in ng-show.
<form name="f1" novalidate ng-submit="Save(emp)">
<div class="form-group">
<div class="row">
<div class="col-sm-4">
<b style="font-family: Arial; text-transform: capitalize; text-align:left ">Enter EmailId</b>
</div>
<div class="col-sm-8 left-addon">
<input type="email" class="form-control" name="Mail" ng-model="Eamil" ng-blur="ChkAvailableEmail()" ng-class="submitted?'ng-dirty':''" required />
<i class="glyphicon glyphicon-envelope"></i>
<span class="Error" ng-show="(f1.Mail.$dirty ||submitted) && f1.Mail.$error.email">Please Enter Your Valied Email</span>
<span class="Error" ng-show="f1.Mail.$error.ChkAvailableEmail">Email in Use Please try new one</span>
</div>
</div>
</div>
</form>
AngularJs
$scope.ChkAvailableEmail = function () {
var chk = {
Email: $scope.Eamil
}
var mail = $Myservice.GetValidEmail(chk);
mail.then(function (d) {
})
}
HomeController.cs
public JsonResult ChkEmail(string Email)
{
var x = (from n in db.Accessors
where n.Email == Email
select n).FirstOrDefault();
return new JsonResult { Data = x, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}

Related

login validation and credentials using angularjs

I am new to angularjs. I have created simple login page. The code is working fine, but my validation and credentials have some problem. I found some clues in few sites, but those answers din't provide the proper information for my solution. The error that I am facing is in the validation. When I enter the invalid mailid and password it should pop-up error message . But I could not achieve it.
HTML :
`<form ng-submit="loginform()" class="ng-scope ng-pristine ng-valid center" name="logform"><br/><br>`
<div class="form-group col-md-4">
<label form="emailinput"><b>Email</b></label>
<input type="email" class="form-control" name="uname" id="emailinput" placeholder="you#example.com" ng-model="username" ng-pattern="emailFormat">
<span ng-show="logform.uname.$dirty.username && loginform.uname.$invalid"></span>
<span style="color: Red" ng-show="logform.uname.$valid">* Email is required</span>
<span style="color: Red" ng-show="logform.uname.$error.username">* Invalid ID </span>
</div>
<div class="form-group col-md-4">
<label form="pwdinput"><b>Password</b></label>
<input type="password" class="form-control" name="pwd" id="pwdinput" placeholder="*******" ng-model="password">
<span style="color: red" ng-show="logform.pwd.$dirty && loginform.pwd.$invalid"></span>
<span ng-show="logform.pwd.$error.$valid">* Password is required</span>
<span ng-show="logform.pwd.$error.pwd">* Invalid Password</span>
</div>
<div class="col-md-4">
<button type="cancel" class="btn" ng-click="toggle_cancel()">Cancel</button>
<button class="btn btn-primary" ng-click="submit()" ng-Disabled="logform.username.$dirty && loginform.username.$invalid || logform.pwd.$dirty && loginform.pwd.$invalid">Login</button>
</div>
AngularJs :
`var app = angular.module('logapp',['toastr']);`
app.factory('authentication', function() {
return {
isAuthenticated: false,
user: null
}
});
app.controller('credientials', function($scope,toastr,authentication) {
$scope.loginform = function (username, password) {
if ($scope.username === 'admin#evol.com' && $scope.password === '123') {
authentication.isAuthenticated = true;
$location.path("/home");
} else {
toastr.error('Invalid username and password');
}
};
});
Kindly read the snippet below and alter your code to setValidity() based on condition.
var app = angular.module('logapp', []);
app.factory('authentication', function() {
return {
isAuthenticated: false,
user: null
}
});
app.controller('credientials', function($scope, authentication) {
$scope.loginform = function(isValid) {
$scope.logform.uname.$setValidity("username", true);
$scope.logform.pwd.$setValidity("pwd", true);
if (isValid) {
if ($scope.username == 'admin#evol.com' && $scope.password == '123') {
alert("success");
authentication.isAuthenticated = true;
} else {
$scope.logform.uname.$setValidity("username", false);
$scope.logform.pwd.$setValidity("pwd", false);
}
}
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="logapp" ng-controller="credientials">
<form ng-submit="loginform(logform.$valid)" class="ng-scope ng-pristine ng-valid center" name="logform" novalidate role="form">
<div class="form-group col-md-4">
<label form="emailinput"><b>Email</b></label>
<input type="email" class="form-control" name="uname" id="emailinput" placeholder="you#example.com" ng-model="username" ng-pattern="emailFormat" required>
<span style="color: Red" ng-show="logform.$submitted && logform.uname.$error.required">* Email is required</span>
<span style="color: Red" ng-show="logform.$submitted && logform.uname.$error.username">* Invalid ID </span>
</div>
<div class="form-group col-md-4">
<label form="pwdinput"><b>Password</b></label>
<input type="password" class="form-control" name="pwd" id="pwdinput" placeholder="*******" ng-model="password" required>
<span ng-show="logform.$submitted && logform.pwd.$error.required">* Password is required</span>
<span ng-show="logform.$submitted && logform.pwd.$error.pwd">* Invalid Password</span>
</div>
<div class="col-md-4">
<button type="cancel" class="btn" ng-click="toggle_cancel()">Cancel</button>
<button class="btn btn-primary" type="submit">Login</button>
</div>
</form>
</body>

How to add dynamically html controls through the Angular Js in Asp.Net MVC Project?

How to add dynamically html controls through the Angular Js in Asp.NetMVC Project?
just like-i want to add multiple bank details of employee on add button click.
and how can i remove wrong bank details on other remove button click.
To add dynamically bank details page controls through angular js
Step 1: first of all create html page like below code.
Bank.cshtml page
<form class="form-horizontal" enctype="multipart/form-data">
<div ng-repeat="item in ArrBankCtrls">
<div class="form-group">
<label ng-model="item.bankPK_Id" hidden></label>
<label for="BankName" class="col-sm-2 control-label">Bank <i class="mandatStarColor">*</i></label>
<div class="col-sm-6">
<select class="form-control" style="width: 100%;" ng-change="ChangeBankName()" ng-model="item.BankName">
<option selected="selected">--Select Bank--</option>
<option ng-repeat="item in bankName" value="{{item.Value}}">{{item.Text}}</option>
</select>
<span style="color:red;" ng-show="item.requiredBankName">BankName is required !</span>
</div>
<div class="col-sm-2">
<button id="Add" class="btn btn-success" title="Add" ng-click="AddRemoveBank(true,item)">+</button>
<button class="btn btn-danger" ng-model="RemoveBankCtrl" ng-disabled="RemoveBankCtrl" title="Remove" ng-click="AddRemoveBank(false,item)">-</button>
</div>
</div>
<div class="form-group">
<label for="AccountNo" class="col-sm-2 control-label">A/c No. <i class="mandatStarColor">*</i></label>
<div class="col-sm-6">
<input type="text" class="form-control" onlydigits ng-change="ChangeAccountNo($index)" ng-model="item.AccountNo" placeholder="Account No." maxlength="26" required>
<span style="color:red;" ng-show="item.requiredAccountNo">AccountNo is required !</span>
</div>
</div>
<div class="form-group">
<label for="IFSC" class="col-sm-2 control-label">IFSC <i class="mandatStarColor">*</i></label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-change="ChangeIFSC($index)" ng-model="item.IFSC" placeholder="IFSC" maxlength="11" required>
<span style="color:red;" ng-show="item.requiredIFSC">IFSC is required !</span>
<span style="color:red;" ng-show="item.requiredDigitIFSC">Required 11 digit's !</span>
</div>
</div>
<div class="form-group">
<label for="Address" class="col-sm-2 control-label">Address</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="item.Address" placeholder="Address">
</div>
</div>
<div class="form-group">
<label for="CancelCheque" class="col-sm-2 control-label">Cancel Cheque <i class="mandatStarColor">*</i></label>
<div class="col-sm-6">
<input type="file" id="{{ 'CancelCheque-' + this.$index }}" ng-file-select="onFileSelect($files)" onchange="angular.element(this).scope().BankFileChange(this)" ng-model="item.ImgCancelCheque" upload-file="item.CancelCheque" accept=".pdf,.gif,.jpg,.jpeg,.png,.bmp">
<span style="color:red;" ng-show="item.requiredCancelCheque">CancelCheque file is required !</span>
<img src="{{item.ImgCancelCheque}}" alt="Cancel Cheque" class="imgHeightWidth" />
</div>
</div>
</div>
</form>
Angular Js code
//#region To Add/Remove BankDetails controls
$scope.RemoveBankCtrl = true;
$scope.ArrBankCtrls = [{
PK_Id: "",
BankName: "",
AccountNo: "",
IFSC: "",
Address: "",
CancelCheque: ""
}];
$scope.AddRemoveBank = function (flag, item) {
//debugger
var index = this.$index;
if (flag) {
item = { PK_Id: "", BankName: "", AccountNo: "", IFSC: "", Address: "", CancelCheque: "" };
$scope.ArrBankCtrls.push(item);
$scope.RemoveBankCtrl = false;
//#region Set default selected value in ddl
$scope.ArrBankCtrls[($scope.ArrBankCtrls.length - 1)].BankName = "--Select Bank--";
// #endregion
}
else {
//$scope.ArrBankCtrls.pop(item);
$scope.ArrBankCtrls.splice(index, 1);
if ($scope.ArrBankCtrls.length == 1) {
$scope.RemoveBankCtrl = true;
}
}
}
//#region Bind Bank Name ddl
$scope.ArrBankCtrls[0].BankName = "--Select Bank--";
VendorService.postData(strVenUrl + "/GetBank").then(function (data) {
if (data != null) {
$scope.bankName = data;
}
})
// #endregion
// #endregion
Controller.cs Code
#region GetBank
public ActionResult GetBank()
{
dynamic bank = null;
try
{
bank = vendor.Bank();
}
catch (Exception ex)
{
ExceptionError(ex.Message);
}
return Json(bank, JsonRequestBehavior.AllowGet);
}
#endregion
[HttpPost]
public ActionResult InsertBankDetails(List<BankDetails> bankDetails)
{
//Your code
return RedirectToAction("BankDetails");
}
you must have used somewhere collections, bind that collection in the ng-repeat directive, on the button click and add simply remove and add an item from the collection

Angular Js Validation on Partial Views

Index Page
#model AngularMVC.Models.Employee
#{
ViewBag.Title = "Home Page";
}
<style>
input.ng-touched.ng-invalid {
border: 1px solid red;
}
input.ng-touched.ng-valid
{
border: 1px solid #48bb00;
}
li{
border:1px solid blue;
font-size:2em;
color:Green;
}
</style>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/angular-route.min.js"></script>
<script src="~/Scripts/Custom/modules.js"></script>
<div ng-app="myApp">
<form ng-controller="validateCtrl"
name="myForm" novalidate ng-submit="submit()">
<span ng-show="isViewLoading">
<img src="~/Content/images/box.gif" /> loading...
</span>
<div class="{{status}}">{{message}}</div>
<p>
<b>Name:</b> <br>
#Html.TextBoxFor(m => m.Name, new { #class = "form-control", #ng_required = "true", ng_model = "Model.name", Name = "name" })
<span style="color:red" ng-show="myForm.name.$dirty && myForm.name.$invalid">
<span ng-show="myForm.name.$error.required">Username is required.</span>
</span>
</p>
<p>
<b>Email:</b><br>
#Html.TextBoxFor(m => m.Email, new { #class = "form-control", #ng_required = "true", ng_model = "Model.email", Name = "email", type = "email" })
<span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
<span ng-show="myForm.email.$error.required">Email is required.</span>
<span ng-show="myForm.email.$error.email">Invalid email address.</span>
</span>
</p>
<p>
<b>Password:</b><br />
#Html.PasswordFor(m => m.Password, new { ng_model = "Model.password", #ng_required = "true", #class = "form-control", ng_minlength = "8", ng_maxlength = "16", Name = "password" })
<span style="color:red" ng-show="myForm.password.$dirty && myForm.password.$invalid">
<span ng-show="myForm.pass.$error.required">Password is required.</span>
<span ng-show="myForm.password.$touched && myForm.password.$error.minlength">Passord must be 8-16 character</span>
<span ng-show="myForm.password.$touched && myForm.password.$error.maxlength">Passord must be 8-16 character</span>
</span>
</p>
<p>
<input type="submit" ng-disabled="myForm.$invalid" value="Submit">
</p>
</form>
#*<p>Main</p>
First*#
Second
<div class="panel panel-default">
<div class="panel-heading">
{{PanelHeading}}
</div>
<div ng-view class="panel-body">
</div>
</div>
</div>
Module.js
var app = angular.module('myApp', ['ngRoute']);
app.controller('validateCtrl', function ($scope, $http) {
$scope.submit = function () {
//$scope.model = #Html.Raw(Json.Encode(Model));
$scope.isViewLoading = true;
$http({
method: "post",
url: "/Home/Create",
data: { emp: $scope.Model }
}).success(function (data, status, header, config) {
if (data = "Success") {
$scope.status = "text-success";
$scope.message = "Data successfully submitted";
}
else {
$scope.status = "text-warning";
$scope.message = "Failed to insert Data";
}
}).error(function (data, status, header, config) {
$scope.status = "text-danger";
$scope.message = 'Unexpected Error while saving data!!';
});
$scope.isViewLoading = false;
}
});
// Routes Provider for SPA
app.config(function ($routeProvider) {
$routeProvider
.when('/first', {
templateUrl: '/Home/first',
controller: 'HomeController',
})
.when('/second', {
templateUrl: '/Home/Second',
controller: 'HomeController'
})
});
Partial View Having a signup form
<div>
<form action="/Home/SignUp" name="signupForm">
<p>
<b>First Name:</b><br />
<input type="text" class="form-control" ng-required="true" ng-model="fname" name="fname" />
<span ng-show="signupForm.fname.$dirty&&signupForm.fname.$invalid" style="color:red">
<span ng-show="signupForm.fname.$error.required">First Name is required</span>
</span>
</p>
<p>
<b>Last Name:</b><br />
<input type="text" class="form-control" ng-required="true" ng-model="lname" name="lname"/>
<span ng-show="signupForm.lname.$dirty&&signupForm.lname.$invalid" style="color:red">
<span ng-show="signupForm.lname.$error.required">Last Name is required</span>
</span>
</p>
<p>
<b>Email:</b><br />
<input type="email" class="form-control" ng-required="true" name="email" ng-model="email"/>
<span ng-show="signupForm.email.$dirty&&signupForm.email.$invalid" style="color:red">
<span ng-show="signupForm.email.$error.required">Email is required</span>
<span ng-show="signupForm.email.$error.email"></span>
</span>
</p>
<p>
<b>Age:</b><br />
<input type="number" class="form-control" ng-required="true" ng-model="age"/>
<span ng-show="signupForm.age.$dirty&&signupForm.age.$invalid" style="color:red">
<span ng-show="signupForm.age.$error.required">Age is required</span>
<span ng-show="signupForm.age.$error.max ||signupForm.age.$error.min ">Age must be in between 18- 60 years</span>
</span>
</p>
<p>
<b>Password:</b><br />
<input type="password" class="form-control" ng-required="true" ng-model="password" name="password" ng-maxlength="16" ng-minlength="8"/>
<span ng-show="signupForm.password.$dirty&&signupForm.password.$invalid" style="color:red">
<span ng-show="signupForm.password.$error.required">Passowrd is required</span>
<span ng-show="signupForm.password.$error.maxlength ||signupForm.password.$error.minlength "></span>
</span>
</p>
<p>
<b>Confirm Password:</b><br />
<input type="password" class="form-control" ng-required="true" ng-model="conPassword" name="conPassword" ng-maxlength="16" ng-minlength="8" ng-equal="password"/>
<span ng-show="signupForm.conPassword.$dirty&&signupForm.conPassword.$invalid" style="color:red">
<span ng-show="signupForm.conPassword.$error.required">Passowrd is required</span>
<span ng-show="signupForm.conPassword.$error.maxlength ||signupForm.conPassword.$error.minlength "></span>
<span ng-show="signupForm.conPassword.$error.equal">Password do not match</span>
</span>
</p>
<p>
<b>Upload Profile Picture:</b><br />
<input type="file" value="Upload" /><input type="submit" value="Upload" ng-click="Upload()" ng-required="true"/>
</p>
<input type="submit" value="Submit" class="btn btn-default" ng-disabled="signupForm.$invalid"/>
</form>
I am Loading Partial View inside in ng-view in Index page but angular validation is not working inside the ng-view partial view . Please help anyone?

How to reset Bootstrap Form

Here im using Bootstrap validations with AngularJs when my form is submitted the columns is reset but its shows all validation..But my aim is its should not display validations
Bootstrap
<div class="modal" id="modal1">
<div class="modal-dialog">
<div class="modal-content">
<form name="f1" novalidate ng-submit="Save(Auth.emp)">
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group">
<div class="row">
<div class="col-sm-4">
Email
</div>
<div class="col-sm-8">
<input type="text" name="email" class="form-control" ng-model="Auth.Email" ng-class="Submitted?'ng-dirty':''" required />
<span class="Error" ng-show="(f1.email.$dirty ||Submitted) && f1.email.$error.required">Email REq</span>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-4">
Password
</div>
<div class="col-sm-8">
<input type="text" name="psw" class="form-control" ng-model="Auth.Password" ng-class="Submitted?'ng-dirty':''" required />
<span class="Error" ng-show="(f1.psw.$dirty ||Submitted) && f1.psw.$error.required">Password REq</span>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<input type="submit" value="{{LoginAction}}" />
</div>
</form>
</div>
</div>
</div>
AngularCode.Js
$scope.Save = function (emp) {
if ($scope.LoginAction = "Login") {
$scope.Submitted = true;
if ($scope.isFormValid == true) {
var ss = {
Email: $scope.Auth.Email,
Password: $scope.Auth.Password,
}
var xxer = myServices.GetLogin(ss);
xxer.then(function (msg) {
$scope.msg = msg.data;
$('#modal2').modal('show')
Reset();
})
}
}
}
Reset
function Reset() {
$scope.Email = '';
$scope.Password = '';
}
I think you looking for this:
function Reset() {
$scope.Auth.Email = ''
$scope.Auth.Password = '';
}
You can set a model at the same level as the form tag and make all other inputs sub properties. Then set form model at the root level to an empty object when you click on reset. Here's a codepen.
function exampleController($scope) {
$scope.reset = function() {
$scope.form = {};
};
}
angular
.module('app', [])
.controller('exampleController', exampleController);
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<div class="row" ng-app="app" ng-controller="exampleController">
<form novalidate ng-model="form">
<input ng-model="form.email" type="email" />
<input ng-model="form.password" type="password" />
</form>
<button ng-click="reset()">Reset</button>
<pre>{{form}}</pre>
</div>

How can we make show/hide password input in angular js with bootstrap 3?

I want to make show/hide password input in angularjs with Bootstrap 3.
The toggle option needs to be inside the input.
Can you provide a snippet or example on that.
Thanks a million.
You can dynamically change the input type with the ng-attr-type directive. For example:
<input ng-attr-type="{{ showPassword ? 'text' : 'password' }}">
you can tie the showPassword to the click event and make it toggle.
Update (from #Ferie's comment):
HTML
<span class="showPassword" ng-click="togglePassword()">{{ typePassword ? 'Hide' : 'Show' }}</span><br> <input type="{{ typePassword ? 'text' : 'password' }}" name="password" placeholder="Password">
In the Angular Controller
$scope.togglePassword = function () { $scope.typePassword = !$scope.typePassword; };
AngularJS / UI Bootstrap Solution
Use Bootstrap's has-feedback class to show an icon inside the input field.
Make sure the icon has style="cursor: pointer; pointer-events: all;"
Use ng-if to show/hide different forms where the <label type="password"> vs <label type="text">
HTML
<!-- index.html snippet -->
<!-- show password as type="password" -->
<div ng-if="!showPassword"
class="form-group has-feedback">
<label>password</label>
<input type="password"
ng-model="params.password"
class="form-control"
placeholder="type something here...">
<span ng-if="params.password"
ng-click="toggleShowPassword()"
class="glyphicon glyphicon-eye-open form-control-feedback"
style="cursor: pointer; pointer-events: all;">
</span>
</div>
<!-- show password as type="text" -->
<div ng-if="showPassword"
class="form-group has-feedback">
<label>password</label>
<input type="text"
ng-model="params.password"
class="form-control"
placeholder="type something here...">
<span ng-if="params.password"
ng-click="toggleShowPassword()"
class="glyphicon glyphicon-eye-close form-control-feedback"
style="cursor: pointer; pointer-events: all;">
</span>
</div>
JavaScript
// app.js
var app = angular.module('plunker', ['ui.bootstrap']);
app.controller('MainCtrl', function($scope) {
$scope.params = {};
$scope.showPassword = false;
$scope.toggleShowPassword = function() {
$scope.showPassword = !$scope.showPassword;
}
});
Give it as spin with the plunker: http://plnkr.co/edit/oCEfTa?p=preview
you can simply do
<input ng-show="showpassword" type="text" ng-model="password">
<input ng-hide="showpassword" type="password" ng-model="password">
<input type="checkbox" ng-model="showpassword" ng-checked="false">
read here
Here's a working demo:
var app = angular.module('myApp', []);
app.controller('loginCtrl', function($scope) {
$scope.showPassword = false;
$scope.toggleShowPassword = function() {
$scope.showPassword = !$scope.showPassword;
}
});
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form name="form" ng-app="myApp" ng-controller="loginCtrl" novalidate>
<label>
Password:
<input type="password" name="password" ng-model="password" ng-attr-type="{{ showPassword ? 'text':'password'}}" />
<div ng-click="toggleShowPassword()" ng-class="{'fa fa-eye': showPassword,'fa fa-eye-slash': !showPassword}" style="cursor: pointer;"></div>
</label>
</form>
You can also try this one
<input type="{{showPassword?'text':'password'}}" />
<input type="checkbox" title="Show Password" ng-model="showPassword" ng-checked="showPassword">
Using a unique input and toggle his type like this:
<input type="{{inputType}}" placeholder="Put your password" />
Controller
// Set the default value of inputType
$scope.inputType = 'password';
// Hide & show password function
$scope.hideShowPassword = function(){
if ($scope.inputType == 'password')
$scope.inputType = 'text';
else
$scope.inputType = 'password';
};
http://codepen.io/gymbry/pen/fJchw/
The simple and smart way is
<div class="input-group">
<input tabindex="2" type="password" class="form-control input-lg" ng-model="_password" placeholder="password" name="_password" required ng-attr-type="{{ pwd_hide ? 'text':'password'}}">
<span class="input-group-addon" ng-click="pwd_hide = !pwd_hide">{{ pwd_hide ? 'Hide':'Show'}}</span>
</div>
<span ng-show="submitted || loginForm._password.$dirty && loginForm._password.$invalid">
<span ng-show="loginForm._password.$error.required" class="error">Please enter your password.</span>
</span>
<input class="form-control" type="{{passwordType}}" ng-model="User.Password" name="txtPassword" ng-class="submitted?'ng-dirty':''" autofocus required /><i style="position: relative;float: right;top: -26px;right: 3px; cursor:pointer" ng-click="showPassword()" class="ti ti-eye"></i>
App.controller('myCtrl', function ($scope) {
$scope.passwordType = "password";
$scope.showPassword = function () {
if ($scope.passwordType == "password") {
$scope.passwordType = "text";
} else {
$scope.passwordType = "password";
}
}
});
you should try to this one whit eye icons
<div class="col-md-6" ng-init="paninptype='password'; iconimg='/images/icons8-invisible-32.png';">
<label>PAN Number</label>
<div class="input-group">
<input type="{{paninptype}}" class="form-control" name="PAN" ng-model="vm.step1.model.PAN" id="exp-pan" placeholder="e.g. FARPS XXXX G" />
<span class="input-group-addon">
<img src="{{iconimg}}" class="pull-right" style="width:38px" ng-click="paninptype=(paninptype=='password'?'text':'password'); iconimg=(paninptype=='password'?'/images/icons8-invisible-32.png':'/images/icons8-eye-50.png');">
</span>
</div>
</div>
You want the input box to be hidden or show/hide password?
Here is what i have done till now
HTML
<div class="btn-group">
<input ng-hide="hidevar" id="searchinput" type="password" class="form-control" placeholder="password" >
<span id="searchclear" ng-click="hideinpbox();">HIDE</span>
</div>
CSS :
#searchinput {
width: 200px;
}
#searchclear {
position:absolute;
right:5px;
top:0;
bottom:0;
height:14px;
margin-top:7px;
margin-right:5px;
font-size:14px;
cursor:pointer;
color:#ccc;
}
http://plnkr.co/edit/TfKvlh1mM6wsNrPQKY4Q?p=preview

Resources