當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。