Skip to content

Commit 5d42d79

Browse files
feat(Transition): Add the transition source (url/sref) to TransitionOptions
1 parent 8d6090e commit 5d42d79

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

src/ng1/directives/stateDirectives.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ function clickHook(el: IAugmentedJQuery, $state: StateService, $timeout: ITimeou
7878

7979
/** @hidden */
8080
function defaultOpts(el: IAugmentedJQuery, $state: StateService) {
81-
return { relative: stateContext(el) || $state.$current, inherit: true };
81+
return {
82+
relative: stateContext(el) || $state.$current,
83+
inherit: true,
84+
source: "sref"
85+
};
8286
}
8387

8488
/**

src/ng2/directives/uiSref.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ export class UISref {
8888
}
8989

9090
getOptions() {
91-
let defOpts = { relative: this.parent && this.parent.context && this.parent.context.name, inherit: true };
91+
let defOpts: TransitionOptions = {
92+
relative: this.parent && this.parent.context && this.parent.context.name,
93+
inherit: true ,
94+
source: "sref"
95+
};
9296
return extend(defOpts, this.options || {});
9397
}
9498

src/state/stateQueueManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class StateQueueManager {
9696

9797
$urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match: RawParams, $stateParams: RawParams) {
9898
if ($state.$current.navigable !== state || !equalForKeys($match, $stateParams)) {
99-
$state.transitionTo(state, $match, { inherit: true, location: false });
99+
$state.transitionTo(state, $match, { inherit: true, location: false, source: "url" });
100100
}
101101
}]);
102102
}

src/transition/interface.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ export interface TransitionOptions {
7373
* You can define your own Transition Options inside this property and use them, e.g., from a Transition Hook
7474
*/
7575
custom ?: any;
76-
/** @internal */
76+
/** @hidden @internal */
7777
reloadState ?: (State);
78-
/** @internal */
78+
/** @hidden @internal */
7979
previous ?: Transition;
80-
/** @internal */
80+
/** @hidden @internal */
8181
current ?: () => Transition;
82+
/** @hidden @internal */
83+
source ?: "sref"|"url"|"unknown";
8284
}
8385

8486
/** @hidden @internal */

src/transition/transitionService.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export let defaultTransOpts: TransitionOptions = {
3232
notify : true,
3333
reload : false,
3434
custom : {},
35-
current : () => null
35+
current : () => null,
36+
source : "unknown"
3637
};
3738

3839
/**

test/matchers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference path='../typings/jasmine/jasmine.d.ts' />
22
import {equals} from "../src/common/common";
3+
declare var testablePromise;
34

45
beforeEach(function() {
56
jasmine.addMatchers(<any> {

0 commit comments

Comments
 (0)