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


TypeScript Router.navigateByUrl方法代码示例

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


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

示例1: handleError

 private handleError(error: any) {
     let errorMessage: any;
     if (error instanceof HttpErrorResponse) {
         if (error.status === 401 || error.status === 403) {
             this.router.navigateByUrl('');
             this.sms.displayErrorMessage('You are not authenticated to access that page');
         }
         errorMessage = error.error || JSON.stringify(error);
         if (errorMessage.error) {
             errorMessage = errorMessage.error;
         }
         errorMessage = `${error.status} - ${error.statusText || ''}: ${errorMessage}`;
     } else {
         errorMessage = error.message ? error.message : error.toString();
     }
     return throwError(errorMessage);
 }
开发者ID:pastorsj,项目名称:bannablog,代码行数:17,代码来源:response.interceptor.ts

示例2: goTo

 goTo(url: string) {
   if (this.order.billing.name &&
       this.order.billing.email &&
       this.order.billing.address &&
       this.order.billing.city &&
       this.order.billing.state &&
       this.order.billing.zip) {
         this.globalService.order.next(this.order);
         this.router.navigateByUrl(url);
         this.localCart.orderUpdateItems(this.order);
     } else {
         let snackBarRef = this.snackBar.open('You must complete the form', 'OK!', {
           duration: 3000,
           extraClasses: ['warn-snackbar']
         });
     }
 }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:17,代码来源:checkout-billing.component.ts

示例3: handleEnter

	// ---
	// PUBLIC METHODS.
	// ---

	// I navigate to the first item in the filtered list.
	public handleEnter() : void {

		var project = this.filteredProjects.find(
			( filteredProject: FilteredProject ) : boolean => {

				return( filteredProject.isVisible );

			}
		);

		if ( project ) {

			this.router.navigateByUrl( project.resource );

		}

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

示例4: canActivate

	// ---
	// PUBLIC METHODS.
	// ---

	// I determine if the requested route can be activated (ie, navigated to).
	public canActivate(
		activatedRouteSnapshot: ActivatedRouteSnapshot,
		routerStateSnapshot: RouterStateSnapshot
		) : boolean {

		// We don't want this modal to show on page-refresh. As such, if this is a page-
		// refresh, we'll navigate to the same URL less the modal outlet.
		if ( this.isPageRefresh() ) {

			this.router.navigateByUrl( this.getUrlWithoutModal( routerStateSnapshot ) );
			return( false );

		}

		return( true );

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:22,代码来源:do-not-show-modal-on-refresh.guard.ts

示例5: constructor

 constructor(
   public snackBar: MdSnackBar,
   public router: Router,
   public globalService: GlobalService,
   public localCart: LocalCartService,
   private title: Title,
   private meta: Meta
 ) {
   this.states = globalService.states;
   this.order = globalService.order.getValue();
   if (!this.order.shipping) {
     router.navigateByUrl('cart');
   }
   if (this.localCart.orderHasItems() && this.localCart.orderHas('billing')) {
     this.order = this.localCart.orderGetItems();
   }
 }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:17,代码来源:checkout-billing.component.ts

示例6: User

      data => {
        if (data['error']) {
          this.loading = false;

          this.message = {
            type: 'danger',
            message: data['message']
          };
        }else {
          let user = Object.assign(new User(), data['user']);
          user.token = data['token'];
          user.role = user.role.id;
          user.isLogged = true;
          this.store.dispatch({type: SET_VALIDATE_TOKEN, payload: true});
          this.store.dispatch({type: SET_USER, payload: user});
          this.router.navigateByUrl('dashboard/subscriber_project/general');
        }
      }, err => {
开发者ID:UHCToken,项目名称:kyc-gui,代码行数:18,代码来源:confirm-subscribe.component.ts

示例7:

    _router.events.subscribe( e=>{


      console.log( e );
      if( e instanceof NavigationStart ){
        console.log("starting navigation.");
      }

      if( e instanceof NavigationEnd ) {
        console.log("ending navigation.");
      }

      if( e instanceof NavigationError ) {

        let lowerCaseUrl = e.url.toLowerCase();
        this._router.navigateByUrl( lowerCaseUrl);
      }
    })
开发者ID:haoguanjun,项目名称:angular2-router,代码行数:18,代码来源:app.component.ts

示例8:

 }, (err: any) => {
   if (err instanceof HttpErrorResponse) {
     if (err.status === 401) {
       // TODO: Add information about unAuthorized to user and redirect user.
       console.log('We intercepted a 401 boys!!!');
     }
     if (err.status === 404) {
       console.log(err.url);
       console.log('We intercepted a 404 boys!!!');
       const role = localStorage.getItem('Role');
       console.log(role);
       if (role === 'Group' && err.url.includes('contracts')) {
         console.log('Redirecting to newContract');
         this.router.navigateByUrl('contracts/newContract');
       }
     }
   }
 });
开发者ID:onero,项目名称:DigitalThesisRegistration-app,代码行数:18,代码来源:jwt.interceptor.ts

示例9: expect

 .then((_) => {
   ObservableWrapper.subscribe<string>(eventBus, (ev) => {
     if (ev.startsWith('deactivate')) {
       completer.resolve(true);
       fixture.detectChanges();
       expect(fixture.debugElement.nativeElement).toHaveText('parent {deactivate cmp}');
     }
   });
   rtr.navigateByUrl('/a').then((_) => {
     fixture.detectChanges();
     expect(fixture.debugElement.nativeElement).toHaveText('A');
     expect(log).toEqual([
       'deactivate: /child-deactivate -> null',
       'parent deactivate: /parent-deactivate -> /a'
     ]);
     async.done();
   });
 });
开发者ID:davewragg,项目名称:angular,代码行数:18,代码来源:lifecycle_hook_spec.ts

示例10: canActivate

	// ---
	// PUBLIC METHODS.
	// ---

	// I determine if the requested route can be activated (ie, navigated to).
	public canActivate(
		activatedRouteSnapshot: ActivatedRouteSnapshot,
		routerStateSnapshot: RouterStateSnapshot
		) : boolean {

		// We don't want to render this secondary view on page-refresh. As such, if this
		// is a page-refresh, we'll navigate to the same URL less the secondary outlet.
		if ( this.isPageRefresh() ) {

			console.warn( "Secondary view not allowed on refresh." );
			this.router.navigateByUrl( this.getUrlWithoutSecondary( routerStateSnapshot ) );
			return( false );

		}

		return( true );

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:23,代码来源:do-not-show-secondary-on-refresh.guard.ts


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