angular.js module to (auto-)focus form elements
1 person uses it
Author: 332905?v=3 ds82


angular module to (auto-)focus form elements


npm install ng-focusme

howto use

  • download or install via npm
  • include JS file in your code base
  • add module dependency to your app

angular.module('app', ['io.dennis.focusme']);


If you just want to use the autofocus feature, just add the directive to your HTML and pass it a truthy arguments:

activate input via function

Sometimes you need to focus an element after an event or explicit via a function call. To achieve this, this package contains a service that can focus any registered element (*without* traversing the DOM):

angular.module('app').controller('SomeCtrl', SomeCtrl); SomeCtrl.$inject = ['FocusMe']; function SomeCtrl($focusme) { ... $focusme.focus('some'); ... }

The parameter passed to $focusme.focus() is the focusme-id of the element. You can explicit define a focusme-id using the focusme-id attribute:

If you don't define it, focusme uses the elements ID or name (id before name).



comments powered by Disqus
This page was last updated over 3 years ago.