Skip to content

Commit d3942a6

Browse files
feat(uiSref): switch custom events prop from event: to events:
1 parent a92d284 commit d3942a6

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/directives/stateDirectives.ts

+23-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function bindEvents(element: IAugmentedJQuery, scope: IScope, hookFn: (e: JQuery
101101
let events;
102102

103103
if (uiStateOpts) {
104-
events = uiStateOpts.event;
104+
events = uiStateOpts.events;
105105
}
106106

107107
if (!isArray(events)) {
@@ -182,13 +182,23 @@ function bindEvents(element: IAugmentedJQuery, scope: IScope, hookFn: (e: JQuery
182182
*
183183
* ### Transition Options
184184
* You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ui-sref-opts` attribute.
185-
* Options are restricted to `location`, `inherit`, `reload`, and `event`.
185+
* Options are restricted to `location`, `inherit`, and `reload`.
186186
*
187187
* #### Example:
188188
* ```html
189189
* <a ui-sref="home" ui-sref-opts="{ reload: true }">Home</a>
190190
* ```
191191
*
192+
* ### Other DOM Events
193+
*
194+
* You can also customize which DOM events to respond to (instead of `click`) by
195+
* providing an `events` array in the `ui-sref-opts` attribute.
196+
*
197+
* #### Example:
198+
* ```html
199+
* <input type="text" ui-sref="contacts" ui-sref-opts="{ events: ['change', 'blur'] }">
200+
* ```
201+
*
192202
* ### Highlighting the active link
193203
* This directive can be used in conjunction with [[uiSrefActive]] to highlight the active link.
194204
*
@@ -340,14 +350,24 @@ uiSref = ['$uiRouter', '$timeout',
340350
*
341351
* ### Transition Options
342352
* You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ui-state-opts` attribute.
343-
* Options are restricted to `location`, `inherit`, `reload`, and `event`.
353+
* Options are restricted to `location`, `inherit`, and `reload`.
344354
* The value of the `ui-state-opts` is `$watch`ed and evaluated as an expression.
345355
*
346356
* #### Example:
347357
* ```html
348358
* <a ui-state="returnto.state" ui-state-opts="{ reload: true }">Home</a>
349359
* ```
350360
*
361+
* ### Other DOM Events
362+
*
363+
* You can also customize which DOM events to respond to (instead of `click`) by
364+
* providing an `events` array in the `ui-state-opts` attribute.
365+
*
366+
* #### Example:
367+
* ```html
368+
* <input type="text" ui-state="contacts" ui-state-opts="{ events: ['change', 'blur'] }">
369+
* ```
370+
*
351371
* ### Highlighting the active link
352372
* This directive can be used in conjunction with [[uiSrefActive]] to highlight the active link.
353373
*

test/stateDirectivesSpec.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ describe('uiStateRef', function() {
555555
it('should bind single HTML events', inject(function($compile, $state, $timeout) {
556556
expect($state.current.name).toEqual('top');
557557

558-
el = angular.element('<input type="text" ui-state="state" ui-state-opts="{ event: [\'change\'] }">');
558+
el = angular.element('<input type="text" ui-state="state" ui-state-opts="{ events: [\'change\'] }">');
559559

560560
scope.state = 'contacts';
561561
$compile(el)(scope);
@@ -570,7 +570,7 @@ describe('uiStateRef', function() {
570570
it('should bind multiple HTML events', inject(function($compile, $state, $timeout) {
571571
expect($state.current.name).toEqual('top');
572572

573-
el = angular.element('<input type="text" ui-state="state" ui-state-opts="{ event: [\'change\', \'blur\'] }">');
573+
el = angular.element('<input type="text" ui-state="state" ui-state-opts="{ events: [\'change\', \'blur\'] }">');
574574

575575
scope.state = 'contacts';
576576
$compile(el)(scope);
@@ -593,7 +593,7 @@ describe('uiStateRef', function() {
593593
it('should bind multiple Mouse events', inject(function($compile, $state, $timeout) {
594594
expect($state.current.name).toEqual('top');
595595

596-
el = angular.element('<a ui-state="state" ui-state-opts="{ event: [\'mouseover\', \'mousedown\'] }">');
596+
el = angular.element('<a ui-state="state" ui-state-opts="{ events: [\'mouseover\', \'mousedown\'] }">');
597597

598598
scope.state = 'contacts';
599599
$compile(el)(scope);
@@ -703,7 +703,7 @@ describe('uiStateRef', function() {
703703
}));
704704

705705
it('should bind single HTML events', inject(function($rootScope, $compile, $state, $timeout) {
706-
el = angular.element('<input type="text" ui-sref="contacts" ui-sref-opts="{ event: [\'change\'] }">');
706+
el = angular.element('<input type="text" ui-sref="contacts" ui-sref-opts="{ events: [\'change\'] }">');
707707
$compile(el)($rootScope);
708708
$rootScope.$digest();
709709

@@ -716,7 +716,7 @@ describe('uiStateRef', function() {
716716
}));
717717

718718
it('should bind multiple HTML events', inject(function($rootScope, $compile, $state, $timeout) {
719-
el = angular.element('<input type="text" ui-sref="contacts" ui-sref-opts="{ event: [\'change\', \'blur\'] }">');
719+
el = angular.element('<input type="text" ui-sref="contacts" ui-sref-opts="{ events: [\'change\', \'blur\'] }">');
720720
$compile(el)($rootScope);
721721
$rootScope.$digest();
722722

@@ -737,7 +737,7 @@ describe('uiStateRef', function() {
737737
}));
738738

739739
it('should bind multiple Mouse events', inject(function($rootScope, $compile, $state, $timeout) {
740-
el = angular.element('<a ui-sref="contacts" ui-sref-opts="{ event: [\'mouseover\', \'mousedown\'] }">');
740+
el = angular.element('<a ui-sref="contacts" ui-sref-opts="{ events: [\'mouseover\', \'mousedown\'] }">');
741741
$compile(el)($rootScope);
742742
$rootScope.$digest();
743743

0 commit comments

Comments
 (0)