Skip to content

AngularJS directive that will trigger focus on an element under specified conditions

License

Notifications You must be signed in to change notification settings

pieterjandesmedt/ng-focus-if

 
 

Repository files navigation

ng-focus-if

NPM version Downloads devDependency Status

An attribute directive that will trigger focus on an element under specified conditions. It can also be used as a cross-browser replacement for the autofocus attribute.

It is available through NPM:

npm install ng-focus-if

Or, via bower:

bower install hiebj/ng-focus-if --save

Usage

Include focusIf.min.js in your build or directly with a <script> tag and require the module in your module definition:

angular  
    .module('App', [  
        'focus-if',  
        ... // other dependencies  
    ]);

To immediately focus an element upon rendering (similar to autofocus):

<input focus-if />

To focus an element when a specified conditional $scope property becomes truthy:

<input focus-if="focusInput" />

To focus an element after a specified delay upon rendering:

<input focus-if focus-delay="500" />

To focus an element after a specified delay when a specified conditional $scope property becomes truthy:

<input focus-if="focusInput" focus-delay="500" />

About

AngularJS directive that will trigger focus on an element under specified conditions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%