Skip to content

Commit f06f6b6

Browse files
feat(Transition): Expose the transition's TargetState as targetState()
1 parent 5d42d79 commit f06f6b6

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/transition/transition.ts

+23-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export class Transition implements IHookRegistry {
4747
static diToken = Transition;
4848

4949
$id: number;
50-
success: boolean;
5150

5251
/**
5352
* A reference to the [[UIRouter]] instance
@@ -58,18 +57,26 @@ export class Transition implements IHookRegistry {
5857

5958
/** @hidden */
6059
private _deferred = services.$q.defer();
61-
/** @hidden */
62-
private _error: any;
6360
/**
6461
* This promise is resolved or rejected based on the outcome of the Transition.
6562
*
6663
* When the transition is successful, the promise is resolved
6764
* When the transition is unsuccessful, the promise is rejected with the [[TransitionRejection]] or javascript error
6865
*/
6966
promise: Promise<any> = this._deferred.promise;
67+
/**
68+
* A boolean which indicates if the transition was successful
69+
*
70+
* After a successful transition, this value is set to true.
71+
* After a failed transition, this value is set to false.
72+
*/
73+
success: boolean;
74+
/** @hidden */
75+
private _error: any;
7076

7177
private _options: TransitionOptions;
7278
private _treeChanges: TreeChanges;
79+
private _targetState: TargetState;
7380

7481
/** @inheritdoc */
7582
onBefore (matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions) : Function { throw ""; };
@@ -102,6 +109,8 @@ export class Transition implements IHookRegistry {
102109
*/
103110
constructor(fromPath: PathNode[], targetState: TargetState, router: UIRouter) {
104111
this.router = router;
112+
this._targetState = targetState;
113+
105114
if (!targetState.valid()) {
106115
throw new Error(targetState.error());
107116
}
@@ -155,6 +164,17 @@ export class Transition implements IHookRegistry {
155164
return this.$to().self;
156165
}
157166

167+
/**
168+
* Gets the Target State
169+
*
170+
* A transition's [[TargetState]] encapsulates the [[to]] state, the [[params]], and the [[options]].
171+
*
172+
* @returns the [[TargetState]] of this Transition
173+
*/
174+
targetState() {
175+
return this._targetState;
176+
}
177+
158178
/**
159179
* Determines whether two transitions are equivalent.
160180
*/

0 commit comments

Comments
 (0)