Skip to content

ngEnter is an angularjs library that triggers an expression when the ENTER key is pressed.

License

Notifications You must be signed in to change notification settings

sun-runners/ngEnter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ngEnter

ngEnter is an angularjs library that triggers an expression when the enter key is pressed.


DEMO

https://kimsunwook.github.io/ngEnter


INSTALL

bower install ng-enter --save

Quick start

Copy-paste the <script> into your <body>.


ngEnter.js

<script src=".bower_components/ng-enter/ngEnter.js"></script>

or

<script src="https://cdn.rawgit.com/KimSunWook/ngEnter/v1.1.3/ngEnter.js"></script>

USAGE

Make sure you include the module 'ngEnter' in your application config

angular.module('myApp', [
  'ngEnter',
  ...
]);
<input
  <!-- Invoked when you press the ENTER key -->
  ng-enter="message = 'ENTER is pressed.'"

  <!-- Called after duration (ms) after pressing the ENTER key. -->
  ng-enter-after="message = 'ENTER was pressed 1 second ago.'"

  <!-- If you do not put object, $enter and $entered values ​​are stored in scope. -->
  ng-enter-model="model"

  <!-- The value of $enter lasts true and the default value is 700 (ms). -->
  ng-enter-duration="1000"

  ng-class="[

    <!-- The value of $enter becomes true on click and turns false after duration (ms). -->
    {'enter_classes':model.$enter},

    <!-- The value of $entered is true when clicked and does not change. -->
    {'entered_classes':model.$entered}

  ]">

Once enter is pressed

$scope.message === 'enter pressed' // true
$scope.model.$enter === true // true
$scope.model.$entered === true // true

Easy!

About

ngEnter is an angularjs library that triggers an expression when the ENTER key is pressed.

Resources

License

Stars

Watchers

Forks

Packages

No packages published