• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript common.LocationStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@angular/common.LocationStrategy的典型用法代码示例。如果您正苦于以下问题:TypeScript LocationStrategy类的具体用法?TypeScript LocationStrategy怎么用?TypeScript LocationStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了LocationStrategy类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

  constructor(public platformStrategy: LocationStrategy) {
    super(1);

    platformStrategy.onPopState(event => this._update('pop'));

    const browserBaseHref = this.platformStrategy.getBaseHref();
    this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
    this._update('push');
  }
开发者ID:SekibOmazic,项目名称:router,代码行数:9,代码来源:router.ts


示例2: it

  it('should navigate back', fakeAsync(() => {
    const {fixture, rootRenderer} = initTest(TestComponent, `<View><router-outlet></router-outlet></View>`);
    const location: LocationStrategy = getTestBed().get(LocationStrategy);
    const router: Router = getTestBed().get(Router);
    router.initialNavigation();
    tick();
    fixture.detectChanges();
    rootRenderer.executeCommands();
    expect(mock.commandLogs.toString()).toEqual(
      'CREATE+2+test-cmp+{},CREATE+3+native-view+{},CREATE+4+router-outlet+{},ATTACH+1+2+0,ATTACH+2+3+0,ATTACH+3+4+0,' +
      'CREATE+5+cmp-a+{},CREATE+6+native-text+{},CREATE+7+native-rawtext+{"text":"a"},ATTACH+6+7+0,ATTACH+5+6+0,ATTACH+3+5+1');
    mock.clearLogs();

    router.navigateByUrl('/b')
      .then((_: any) => {
        tick();
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'CREATE+8+cmp-b+{},CREATE+9+native-text+{},CREATE+10+native-rawtext+{"text":"b"},DETACH+3+1,ATTACH+3+8+1,ATTACH+9+10+0,ATTACH+8+9+0');
        mock.clearLogs();
      })
      .then((_: any) => {
        location.back();
        tick();
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'CREATE+11+cmp-a+{},CREATE+12+native-text+{},CREATE+13+native-rawtext+{"text":"a"},DETACH+3+1,ATTACH+3+11+1,ATTACH+12+13+0,ATTACH+11+12+0');
      });
  }));
开发者ID:angular,项目名称:react-native-renderer,代码行数:31,代码来源:router_spec.ts


示例3: constructor

  constructor(public platformStrategy: LocationStrategy) {
    super({ path: _path(platformStrategy), type: 'push' });

    platformStrategy.onPopState(event => this._update('pop'));

    this._baseHref = _getBaseHref(platformStrategy);
  }
开发者ID:gravity-addiction,项目名称:router,代码行数:7,代码来源:router.ts


示例4: constructor

	// I initialize the retro-location service. This provides an API that is 
	// reminiscent of the AngularJS 1.x $location service.
	constructor( locationStrategy: LocationStrategy ) {

		this.locationStrategy = locationStrategy;
		this.popStateEvents = new Subject();

		// When the underlying location implementation emits a PopStateEvent, we 
		// want to communicate that out to any clients that may be subscribed to the
		// RetroLocation events.
		this.locationStrategy.onPopState(
			( event: PopStateEvent | HashChangeEvent ) : void => {

				// Since RetroLocation will emit this event when the location is 
				// changed programmatically, we want to limit it to a single event-type,
				// popstate, in order to make things a bit more predictable.
				if ( event.type === "popstate" ) {

					this.popStateEvents.next({
						url: this.url(),
						pop: true,
						type: "popstate"
					});

				}

			}
		);

	}	
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:30,代码来源:retro-location.ts


示例5: it

  it('should navigate back', async(inject([TestComponentBuilder, ReactNativeRootRenderer], (tcb: TestComponentBuilder, _rootRenderer: ReactNativeRootRenderer) => {
    var rootRenderer = _rootRenderer;
    var router: Router;
    var location: LocationStrategy;
    tcb.createAsync(TestComponent).then((fixture: ComponentFixture<TestComponent>) => {
      router = fixture.componentInstance.router;
      location = fixture.componentInstance.location;
      fixture.detectChanges();
      rootRenderer.executeCommands();
      mock.clearLogs();

      return new Promise((resolve: any) => {
        setTimeout(() => {
          rootRenderer.executeCommands();
          expect(mock.commandLogs.toString()).toEqual(
            'CREATE+5+cmp-a+{},CREATE+6+native-text+{},CREATE+7+native-rawtext+{"text":"a"},ATTACH+6+7+0,ATTACH+5+6+0,ATTACH+3+5+1');
          mock.clearLogs();

          router.navigateByUrl('/b')
          .then((_: any) => {
            rootRenderer.executeCommands();
            expect(mock.commandLogs.toString()).toEqual(
              'CREATE+8+cmp-b+{},CREATE+9+native-text+{},CREATE+10+native-rawtext+{"text":"b"},DETACH+3+1,ATTACH+3+8+1,ATTACH+9+10+0,ATTACH+8+9+0');
            mock.clearLogs();
          })
          .then((_: any) => {
            location.back();
            setTimeout(() => {
              rootRenderer.executeCommands();
              expect(mock.commandLogs.toString()).toEqual(
                'CREATE+11+cmp-a+{},CREATE+12+native-text+{},CREATE+13+native-rawtext+{"text":"a"},DETACH+3+1,ATTACH+3+11+1,ATTACH+12+13+0,ATTACH+11+12+0');
              resolve();
            }, 30);
          });

        }, 0);
      });
    });
  })));
开发者ID:DavyDuDu,项目名称:react-native-renderer,代码行数:39,代码来源:router_spec.ts


示例6: tick

 .then((_: any) => {
   location.back();
   tick();
   fixture.detectChanges();
   rootRenderer.executeCommands();
   expect(mock.commandLogs.toString()).toEqual(
     'CREATE+11+cmp-a+{},CREATE+12+native-text+{},CREATE+13+native-rawtext+{"text":"a"},DETACH+3+1,ATTACH+3+11+1,ATTACH+12+13+0,ATTACH+11+12+0');
 });
开发者ID:angular,项目名称:react-native-renderer,代码行数:8,代码来源:router_spec.ts


示例7: setTimeout

 .then((_: any) => {
   location.back();
   setTimeout(() => {
     rootRenderer.executeCommands();
     expect(mock.commandLogs.toString()).toEqual(
       'CREATE+11+cmp-a+{},CREATE+12+native-text+{},CREATE+13+native-rawtext+{"text":"a"},DETACH+3+1,ATTACH+3+11+1,ATTACH+12+13+0,ATTACH+11+12+0');
     resolve();
   }, 30);
 });
开发者ID:DavyDuDu,项目名称:react-native-renderer,代码行数:9,代码来源:router_spec.ts


示例8: url

	public url( newUrl?: string ) : RetroLocation | string {

		// Return the existing url.
		if ( newUrl === undefined ) {

			return( this.locationStrategy.path( true ) ); // true = Include Hash.

		}

		// Set the new url.
		this.navigate( this.parseUrl( newUrl ) );

		return( this );

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:15,代码来源:retro-location.ts


示例9: navigate

	// I navigate to the location defined by the given URL segments (pathname, search, 
	// and hash).
	private navigate( urlSegments: UrlSegments ) : void {

		var url = urlSegments.pathname;

		if ( urlSegments.search ) {

			url += ( "?" + urlSegments.search );

		}

		if ( urlSegments.hash ) {

			url += ( "#" + urlSegments.hash );

		}

		// Only push the state if the URL has actually changed. We only need this 
		// because the RetroLocation emits an event and we want this event to be a bit 
		// more closely tied to an actual change in the location.
		if ( url !== this.url() ) {

			this.locationStrategy.pushState(
				// pushState - all the other strategies appear to pass NULL here.
				null,
				// title - all the other strategies appear to pass empty-string here.
				"",
				// path - we are encoding the entire location into the path.
				url,
				// queryParams - we are baking these into the path (above).
				""
			);

			this.popStateEvents.next({
				url: url,
				pop: true,
				type: "popstate"
			});
			
		}

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:43,代码来源:retro-location.ts


示例10:

 _goBack() {
   this._locationStrategy.back();
 }
开发者ID:angular,项目名称:react-native-renderer,代码行数:3,代码来源:router.ts



注:本文中的@angular/common.LocationStrategy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript common.PercentPipe类代码示例发布时间:2022-05-28
下一篇:
TypeScript common.Location类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap