jose-marin
8/11/2016 - 3:01 PM

ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)

ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)

app.directive('onEnter', function() {
    return {
        restrict: "A",
        scope: {
            action: "&onEnter"
        },
        link: function(scope, element, attrs) {
            element.on("keydown keypress", function(event) {
                if(event.which === 13) {
                    scope.$apply(scope.action);
                    event.preventDefault();
                }
            });
        }
    };
});