kalai kalai - 29 days ago 12
AngularJS Question

How to make glyphicon-eye open or close in Angularjs?

In my form for each field am using glyphicon-eye and if the user clicks on that eye open icon then it should change to eye close.

I need to call a function during ng-click and if eye is close then i need to pass that field name as key inside array.

<input type="text" name="fname" class="form-control1" autocomplete="off" ng-required="true" ng-model="model.firstName" ng-pattern="/^[a-zA-Z ]*$/" ng-minlength =1 placeholder="First Name"/>
<a id="menu-toggle" ng-click="hiddenFileds()" ng-model="model.fnamei" class="btn btn-default"><i class="glyphicon glyphicon-eye-open"></i></a>

<input type="text" name="lname" class="form-control1" autocomplete="off" ng-required="true" ng-model="model.lastName" ng-pattern="/^[a-zA-Z ]*$/" ng-minlength =1 placeholder="Last Name"/>
<a id="menu-toggle" ng-click="hide()" class="btn btn-default"><i class="glyphicon glyphicon-eye-open"></i></a>

Answer

Try This

<input  type="text" name="fname" class="form-control1" autocomplete="off" ng-required="true" ng-model="model.firstName" ng-pattern="/^[a-zA-Z ]*$/" ng-minlength =1 placeholder="First Name"/>

<a id="menu-toggle" ng-click="hideName = (hideName?false:true)" class="btn btn-default"><i class="glyphicon" ng-class="{'glyphicon-eye-open':!hideName, 'glyphicon-eye-close':hideName}"></i></a>