This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(directive): ng:keydown, ng:keyup
New directives for binding to keydown and keyup events. Closes #1035
- Loading branch information
1 parent
f2d5261
commit e03182f
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
describe('ngKeyup and ngKeydown directives', function() { | ||
var element; | ||
|
||
afterEach(function() { | ||
dealoc(element); | ||
}); | ||
|
||
it('should get called on a keyup', inject(function($rootScope, $compile) { | ||
element = $compile('<input ng-keyup="touched = true">')($rootScope); | ||
$rootScope.$digest(); | ||
expect($rootScope.touched).toBeFalsy(); | ||
|
||
browserTrigger(element, 'keyup'); | ||
expect($rootScope.touched).toEqual(true); | ||
})); | ||
|
||
it('should get called on a keydown', inject(function($rootScope, $compile) { | ||
element = $compile('<input ng-keydown="touched = true">')($rootScope); | ||
$rootScope.$digest(); | ||
expect($rootScope.touched).toBeFalsy(); | ||
|
||
browserTrigger(element, 'keydown'); | ||
expect($rootScope.touched).toEqual(true); | ||
})); | ||
|
||
}); | ||
|