Giter VIP home page Giter VIP logo

ng-focus-on's Introduction

ng-focus-on

An angularjs directive and corresponding factory to make elements focusable. It's easy!

<div ng-controller="AwesomeCtrl">
  <a href="#" ng-click="focusAwesome($event)">Focus on something awesome</a>
  <input focus-on="awesome">
</div>
angular.module('yourModule', [
  ...

  'focusOn',
  ...
]);


...


function AwesomeCtrl($scope, focus) {
  $scope.focusAwesome = function($event) {
    $event.preventDefault();
    focus('awesome');
  };
}

Installing

Credit

Thanks to this answer from blesh on StackOverflow for inspiration: http://stackoverflow.com/a/18295416/298584

Contributing

npm install
npm test

License

MIT.

ng-focus-on's People

Contributors

demands avatar fraserxu avatar goodeggs-terraformer avatar janpaepke avatar jeffreyrodriguez avatar perplexes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-focus-on's Issues

Focus doesn't work on iOS devices

Focus is ignored by iOS devices because of the timeout we use to defer the event broadcast to the next tick. I have a partial solution and will send a pull request.

Focus on an element in a modal dialog

Hi,
I want to focus on an input each time I open a modal, so I injected your service into the modal's controller, but it doesn't focus on the input unless I wrap the focus() call inside some timeout function :

// What I do
function LoginModalCtrl ($scope, $modalInstance, focus, $timeout) {
        $timeout(function() {
            focus('userCode');
        }, 0);
    };

// What I want
function LoginModalCtrl ($scope, $modalInstance, focus) {
            focus('userCode');
    };

Is there a way to achieve the second one ? :)

Make sure we pass in an argument to focusOn directive #10

When used in an ng-repeat loop, I only wanted it to trigger focus on first item, so I did something like this:

<a ... focus-on="{{$first ? 'focus-just-on-me' : '' }}>...</a>

However, that made it add listeners even for when focus-on was not defined.

PR at #10 if interested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.