Skip to content

Instantly share code, notes, and snippets.

@lean-stack
Created April 15, 2016 13:15
Show Gist options
  • Save lean-stack/202da9bb50eb4449ffac88c8cca37d20 to your computer and use it in GitHub Desktop.
Save lean-stack/202da9bb50eb4449ffac88c8cca37d20 to your computer and use it in GitHub Desktop.

Revisions

  1. @michael-alt michael-alt created this gist Apr 15, 2016.
    20 changes: 20 additions & 0 deletions ngEnter.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    (function() {
    'use strict';

    angular.module('todoApp')
    .directive('enterPressed', function() {
    return {
    restrict: 'A',
    scope: {
    enterPressed: '&'
    },
    link: function(scope,$elt,attrs){
    $elt.on('keypress', function(ev) {
    if( ev.which === 13 ) {
    scope.$apply( function() {scope.enterPressed();});
    }
    });
    }
    };
    });
    }());