I have a search input field and a listbox,
<input type="text" class="inputSearch" placeholder="Search" ng-model="searchRoleOne"/>
<i class="fa fa-search"></i>
<select multiple class="listMutiple top5" ng-model="selectedRoleValue">
<option ng-selected="selectrole" ng-repeat="role in roles | filter:searchRoleOne" value="{{role}}">{{role}}</option>
</select>
I need to addclass say
.addClear{
background: url(../images/Close.png) no-repeat right -10px center;
background-repeat: no-repeat;
background-position: right 5px center;
}
whenever there is text, i should happen on change function. And on clicking the .addClear class search field should get empty and so does the ng-model.
How can i do this?
I tried using ng-class="{'addClear': searchRoleOne}"
in search field. It isn't working properly.
I have a search input field and a listbox,
<input type="text" class="inputSearch" placeholder="Search" ng-model="searchRoleOne"/>
<i class="fa fa-search"></i>
<select multiple class="listMutiple top5" ng-model="selectedRoleValue">
<option ng-selected="selectrole" ng-repeat="role in roles | filter:searchRoleOne" value="{{role}}">{{role}}</option>
</select>
I need to addclass say
.addClear{
background: url(../images/Close.png) no-repeat right -10px center;
background-repeat: no-repeat;
background-position: right 5px center;
}
whenever there is text, i should happen on change function. And on clicking the .addClear class search field should get empty and so does the ng-model.
How can i do this?
I tried using ng-class="{'addClear': searchRoleOne}"
in search field. It isn't working properly.
2 Answers
Reset to default 5Simply you can try with this
Fiddle here
ng-class="{'addClear': searchRoleOne.length > 0}"
Hope this may help you
Try
ng-class="{addClear: searchRoleOne.length}"
This should work, see fiddle http://jsfiddle/HB7LU/5613/
what version of angular you using?