@angular/router#DetachedRouteHandle TypeScript Examples

The following examples show how to use @angular/router#DetachedRouteHandle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AemPageRouteReuseStrategy.spec.ts    From aem-angular-editable-components with Apache License 2.0 6 votes vote down vote up
describe('AemPageRouteReuseStrategy', () => {
  let aemPageRouteReuseStrategy: AemPageRouteReuseStrategy;
  let route: ActivatedRouteSnapshot;

  beforeEach(() => {
    aemPageRouteReuseStrategy = new AemPageRouteReuseStrategy();
    route = ({} as any) as ActivatedRouteSnapshot;
  });

  it('should return false when calling shouldDetach(route)', () => {
    expect(aemPageRouteReuseStrategy.shouldDetach(route)).toBe(false);
  });

  it('should return false when calling shouldDetach(route)', () => {
    expect(aemPageRouteReuseStrategy.store({} as ActivatedRouteSnapshot, {} as DetachedRouteHandle)).toBeUndefined();
  });

  it('should return false when calling shouldAttach(route)', () => {
    expect(aemPageRouteReuseStrategy.shouldAttach(route)).toBe(false);
  });

  it('should return null when calling retrieve(route)', () => {
    expect(aemPageRouteReuseStrategy.retrieve(route)).toBeNull();
  });

  it('should return false when calling shouldReuseRoute(route)', () => {
    expect(aemPageRouteReuseStrategy.shouldReuseRoute(route, route)).toBe(false);
  });
});
Example #2
Source File: tab-persist.strategy.ts    From Bridge with GNU General Public License v3.0 5 votes vote down vote up
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle) {
    if (route.data.shouldReuse) {
      this.handles[route.routeConfig.path] = handle
    }
  }
Example #3
Source File: tab-persist.strategy.ts    From Bridge with GNU General Public License v3.0 5 votes vote down vote up
private handles: { [path: string]: DetachedRouteHandle } = {}
Example #4
Source File: AemPageRouteReuseStrategy.ts    From aem-angular-editable-components with Apache License 2.0 5 votes vote down vote up
/** Not storing deteached route. */
  store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void { /* void */ }
Example #5
Source File: AemPageRouteReuseStrategy.ts    From aem-angular-editable-components with Apache License 2.0 5 votes vote down vote up
/** Retrieves the previously stored route. */
  retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null {
    return null;
  }
Example #6
Source File: SearchRouteReuseStrategy.ts    From geonetwork-ui with GNU General Public License v2.0 5 votes vote down vote up
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void {
    this.storedRoutes.set(route.routeConfig.path, handle)
  }
Example #7
Source File: SearchRouteReuseStrategy.ts    From geonetwork-ui with GNU General Public License v2.0 5 votes vote down vote up
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
    return this.storedRoutes.get(route.routeConfig.path)
  }
Example #8
Source File: SearchRouteReuseStrategy.ts    From geonetwork-ui with GNU General Public License v2.0 5 votes vote down vote up
private storedRoutes = new Map<string, DetachedRouteHandle>()
Example #9
Source File: reuse-strategy.ts    From ng-ant-admin with MIT License 5 votes vote down vote up
// 获取存储路由
  retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
    const key = this.getKey(route);
    return !key ? null : SimpleReuseStrategy.handlers[key];
  }