feature(router): add route.root returning the root of router state
This commit is contained in:
parent
5a99393355
commit
1a41bd1ca4
|
@ -119,6 +119,8 @@ export class ActivatedRoute {
|
||||||
|
|
||||||
get routeConfig(): Route { return this._futureSnapshot.routeConfig; }
|
get routeConfig(): Route { return this._futureSnapshot.routeConfig; }
|
||||||
|
|
||||||
|
get root(): ActivatedRoute { return this._routerState.root; }
|
||||||
|
|
||||||
get parent(): ActivatedRoute { return this._routerState.parent(this); }
|
get parent(): ActivatedRoute { return this._routerState.parent(this); }
|
||||||
|
|
||||||
get firstChild(): ActivatedRoute { return this._routerState.firstChild(this); }
|
get firstChild(): ActivatedRoute { return this._routerState.firstChild(this); }
|
||||||
|
@ -207,6 +209,8 @@ export class ActivatedRouteSnapshot {
|
||||||
|
|
||||||
get routeConfig(): Route { return this._routeConfig; }
|
get routeConfig(): Route { return this._routeConfig; }
|
||||||
|
|
||||||
|
get root(): ActivatedRouteSnapshot { return this._routerState.root; }
|
||||||
|
|
||||||
get parent(): ActivatedRouteSnapshot { return this._routerState.parent(this); }
|
get parent(): ActivatedRouteSnapshot { return this._routerState.parent(this); }
|
||||||
|
|
||||||
get firstChild(): ActivatedRouteSnapshot { return this._routerState.firstChild(this); }
|
get firstChild(): ActivatedRouteSnapshot { return this._routerState.firstChild(this); }
|
||||||
|
|
|
@ -35,6 +35,11 @@ describe('RouterState & Snapshot', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return root', () => {
|
it('should return root', () => {
|
||||||
|
const b = state.root.firstChild;
|
||||||
|
expect(b.root).toBe(state.root);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return parent', () => {
|
||||||
const b = state.root.firstChild;
|
const b = state.root.firstChild;
|
||||||
expect(b.parent).toBe(state.root);
|
expect(b.parent).toBe(state.root);
|
||||||
});
|
});
|
||||||
|
@ -72,6 +77,11 @@ describe('RouterState & Snapshot', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return root', () => {
|
it('should return root', () => {
|
||||||
|
const b = state.root.firstChild;
|
||||||
|
expect(b.root).toBe(state.root);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return parent', () => {
|
||||||
const b = state.root.firstChild;
|
const b = state.root.firstChild;
|
||||||
expect(b.parent).toBe(state.root);
|
expect(b.parent).toBe(state.root);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue