Skip to content

dcohenb/angular-clear-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Angular Clear Input

A simple AngularJS plugin that adds a clear button to input boxes

Installation

  1. Download and import the plugin script.
    <script type="text/javascript" src="lib/angular-clear-input/angular.dcb-clear-input.min.js"></script>
  2. Add dcbClearInput to your angular app module dependencies list.
    angular.module('myAngularApp', ['dcbClearInput']);
  3. Add the clear-input attribute to yout input
    <input type="text" ng-model="myModel" clear-input />

Usage

  • Simple usage:
    <input type="text" ng-model="myModel" clear-input />

  • Using on a textarea:
    <textarea ng-model="myModel" clear-input></textarea>

  • Expression:
    <input type="text" ng-model="myModel" clear-input="myModel = 'newVal'" />

  • Function Call:
    <input type="text" ng-model="myModel" clear-input="doSomething()" />

Advanced options

  • Add a class to the appended button, Defaults to: 'clear-btn'.
    <input type="text" ng-model="myModel" clear-input clear-btn-class="custom-class" />

  • Replace the button HTML markup with a custom one, Defaults to: 'X'.
    <input type="text" ng-model="myModel" clear-input clear-btn-markup="<img src='clear.png' />" />

  • Prevant the automatic toggling of the css visibilty property for the clear button
    <input type="text" ng-model="myModel" clear-input clear-disable-visibility="true" />

About

A clear input plugin for angualrjs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •