This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 3 files changed +19
-8
lines changed
3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,6 @@ function publishExternalAPI(angular){
88
88
ngPluralize : ngPluralizeDirective ,
89
89
ngRepeat : ngRepeatDirective ,
90
90
ngShow : ngShowDirective ,
91
- ngSubmit : ngSubmitDirective ,
92
91
ngStyle : ngStyleDirective ,
93
92
ngSwitch : ngSwitchDirective ,
94
93
ngSwitchWhen : ngSwitchWhenDirective ,
Original file line number Diff line number Diff line change 37
37
*/
38
38
var ngEventDirectives = { } ;
39
39
forEach (
40
- 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress' . split ( ' ' ) ,
40
+ 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit ' . split ( ' ' ) ,
41
41
function ( name ) {
42
42
var directiveName = directiveNormalize ( 'ng-' + name ) ;
43
43
ngEventDirectives [ directiveName ] = [ '$parse' , function ( $parse ) {
@@ -224,7 +224,7 @@ forEach(
224
224
* attribute**.
225
225
*
226
226
* @element form
227
- * @param {expression } ngSubmit {@link guide/expression Expression } to eval.
227
+ * @param {expression } ngSubmit {@link guide/expression Expression } to eval. (Event object is available as `$event`)
228
228
*
229
229
* @example
230
230
<doc:example>
@@ -264,8 +264,3 @@ forEach(
264
264
</doc:scenario>
265
265
</doc:example>
266
266
*/
267
- var ngSubmitDirective = ngDirective ( function ( scope , element , attrs ) {
268
- element . on ( 'submit' , function ( ) {
269
- scope . $apply ( attrs . ngSubmit ) ;
270
- } ) ;
271
- } ) ;
Original file line number Diff line number Diff line change @@ -21,5 +21,22 @@ describe('event directives', function() {
21
21
browserTrigger ( element . children ( ) [ 0 ] ) ;
22
22
expect ( $rootScope . submitted ) . toEqual ( true ) ;
23
23
} ) ) ;
24
+
25
+ it ( 'should expose event on form submit' , inject ( function ( $rootScope , $compile ) {
26
+ $rootScope . formSubmission = function ( e ) {
27
+ if ( e ) {
28
+ $rootScope . formSubmitted = 'foo' ;
29
+ }
30
+ } ;
31
+
32
+ element = $compile ( '<form action="" ng-submit="formSubmission($event)">' +
33
+ '<input type="submit"/>' +
34
+ '</form>' ) ( $rootScope ) ;
35
+ $rootScope . $digest ( ) ;
36
+ expect ( $rootScope . formSubmitted ) . not . toBeDefined ( ) ;
37
+
38
+ browserTrigger ( element . children ( ) [ 0 ] ) ;
39
+ expect ( $rootScope . formSubmitted ) . toEqual ( 'foo' ) ;
40
+ } ) ) ;
24
41
} ) ;
25
42
} ) ;
You can’t perform that action at this time.
0 commit comments