diff --git a/src/AngularPublic.js b/src/AngularPublic.js index 53ad5aabfb4f..15f9cbca499d 100755 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -88,7 +88,6 @@ function publishExternalAPI(angular){ ngPluralize: ngPluralizeDirective, ngRepeat: ngRepeatDirective, ngShow: ngShowDirective, - ngSubmit: ngSubmitDirective, ngStyle: ngStyleDirective, ngSwitch: ngSwitchDirective, ngSwitchWhen: ngSwitchWhenDirective, diff --git a/src/ng/directive/ngEventDirs.js b/src/ng/directive/ngEventDirs.js index 9420f7200b32..ac13f472a08c 100644 --- a/src/ng/directive/ngEventDirs.js +++ b/src/ng/directive/ngEventDirs.js @@ -37,7 +37,7 @@ */ var ngEventDirectives = {}; forEach( - 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress'.split(' '), + 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit'.split(' '), function(name) { var directiveName = directiveNormalize('ng-' + name); ngEventDirectives[directiveName] = ['$parse', function($parse) { @@ -224,7 +224,7 @@ forEach( * attribute**. * * @element form - * @param {expression} ngSubmit {@link guide/expression Expression} to eval. + * @param {expression} ngSubmit {@link guide/expression Expression} to eval. (Event object is available as `$event`) * * @example @@ -264,8 +264,3 @@ forEach( */ -var ngSubmitDirective = ngDirective(function(scope, element, attrs) { - element.on('submit', function() { - scope.$apply(attrs.ngSubmit); - }); -}); diff --git a/test/ng/directive/ngEventDirsSpec.js b/test/ng/directive/ngEventDirsSpec.js index 4aa09fc51194..5b73c2dd6a8b 100644 --- a/test/ng/directive/ngEventDirsSpec.js +++ b/test/ng/directive/ngEventDirsSpec.js @@ -21,5 +21,22 @@ describe('event directives', function() { browserTrigger(element.children()[0]); expect($rootScope.submitted).toEqual(true); })); + + it('should expose event on form submit', inject(function($rootScope, $compile) { + $rootScope.formSubmission = function(e) { + if (e) { + $rootScope.formSubmitted = 'foo'; + } + }; + + element = $compile('
' + + '' + + '
')($rootScope); + $rootScope.$digest(); + expect($rootScope.formSubmitted).not.toBeDefined(); + + browserTrigger(element.children()[0]); + expect($rootScope.formSubmitted).toEqual('foo'); + })); }); });