当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript router.Router类代码示例

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


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

示例1: switch

    .subscribe(action => {
      const { path, query }: RouterMethodCall = action.payload;

      switch (action.type) {
        case routerActions.GO:
          router.go(path, query);
          break;

        case routerActions.REPLACE:
          router.replace(path, query);
          break;

        case routerActions.SEARCH:
          router.search(query);
          break;

        case routerActions.BACK:
          router.back();
          break;

        case routerActions.FORWARD:
          router.forward();
          break;
      }
    });
开发者ID:btroncone,项目名称:router-store,代码行数:25,代码来源:connect.ts

示例2: gotoQueryParams

	// I navigate to the current URL with the given name-value pairs in the query-string.
	// This method is designed to leave all other query-string parameters in place.
	public gotoQueryParams( delta: { [key: string]: any } ) : void {

		var parts = this.router.path().split( "?" );
		var pathString = parts.shift();
		var queryString = parts.shift();
		var updatedQueryParams = parse( queryString );

		for ( var key in delta ) {

			if ( delta[ key ] === null ) {

				delete( updatedQueryParams[ key ] );

			} else {

				updatedQueryParams[ key ] = delta[ key ];

			}

		}


		this.router.go( pathString, updatedQueryParams );

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:27,代码来源:router-utils.ts

示例3: gotoScreen

	public gotoScreen( targetScreenId: number ) : void {

		this.isShowingScreenBrowser = false;

		var currentSection = this.router.path().split( /\//g ).pop();

		this.router.go( `/console/project/${ this.projectId }/screen/${ targetScreenId }/${ currentSection }` );

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:9,代码来源:console-view.component.ts

示例4: persistFilter

	// I persist the current filter to the URL (via a param-based navigation).
	private persistFilter() : void {

		this.router.search({
			filter: this.filter
		});

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:8,代码来源:screens-view.component.ts

示例5: protectRoute

 protectRoute(candidate: TraversalCandidate) {
   if (!tokenNotExpired()) {
     this.router.go('/login');
     return Observable.of(false);
   }
   return Observable.of(true);
 }
开发者ID:danielsuter,项目名称:ng2-camp,代码行数:7,代码来源:authGuard.ts

示例6:

 return observable.catch((err, source) => {
   if (err.status === 401 && !_.endsWith(err.url, 'authenticate')) {
     this._router.go('/login');
     return Observable.empty();
   } else {
     return Observable.throw(err);
   }
 });
开发者ID:enyachoke,项目名称:SavannahAcademia,代码行数:8,代码来源:http.ts

示例7: protectRoute

 protectRoute(candidate: TraversalCandidate) {
   if (tokenNotExpired('auth_token')) {
     return Observable.of(true);
   } else {
     this._router.go('/login');
     return Observable.of(false);
   }
 }
开发者ID:enyachoke,项目名称:SavannahAcademia,代码行数:8,代码来源:auth-guard.ts

示例8:

 .map(res => {
   if (res) {
     return true;
   } else {
     this._router.replace(candidate.route.options.permission.redirectTo);
     return false;
   }
 });
开发者ID:Anshdesire,项目名称:angular2-webpack-kickstart,代码行数:8,代码来源:auth-guard.ts

示例9: interceptError

 private interceptError(error: Error) {
   console.log('error', error);
   if (error.message === 'No JWT present') {
     console.log('no JWT, redirecting to login page');
     this.router.go('/login');
     return true;
   }
   return false;
 }
开发者ID:danielsuter,项目名称:ng2-camp,代码行数:9,代码来源:crud.service.ts

示例10:

 .map(inStore =>  {
                  if(inStore && inStore.length>0){
                                console.log("colleciton-exists.ts = inStore.length ="+inStore.length);
                       return true;
                  }else{
                       if((canidate.locationChange.path ==='/' ||
                           canidate.locationChange.path ==='') ){
                                console.log('colleciton-exists.ts = checkForAlblumCollection = canidate ', canidate)
                                console.log('colleciton-exists.ts = checkForAlblumCollection =  this._router ',  this._router)
                                this._router.go('/audioArtist/find')
                        }
                       return false;
                  }
                });
开发者ID:willSonic,项目名称:ngrx2-tester,代码行数:14,代码来源:collection-exists.ts


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