fix(ngSubmit): expose $event to ngSubmit callback

This commit is contained in:
Wesley Cho
2013-05-23 11:22:55 -04:00
committed by Igor Minar
parent 09a1e7af12
commit 3371fc254a
3 changed files with 19 additions and 8 deletions

View File

@@ -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('<form action="" ng-submit="formSubmission($event)">' +
'<input type="submit"/>' +
'</form>')($rootScope);
$rootScope.$digest();
expect($rootScope.formSubmitted).not.toBeDefined();
browserTrigger(element.children()[0]);
expect($rootScope.formSubmitted).toEqual('foo');
}));
});
});