當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Router.navigateByUrl方法代碼示例

本文整理匯總了TypeScript中angular2/router.Router.navigateByUrl方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Router.navigateByUrl方法的具體用法?TypeScript Router.navigateByUrl怎麽用?TypeScript Router.navigateByUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2/router.Router的用法示例。


在下文中一共展示了Router.navigateByUrl方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: logout

 logout() {
     localStorage.removeItem('jwt');
     //var messagesRef = new Firebase(Login.firebaseUrl);
     Login.messagesRef.unauth();
     this.ss.setlevel(0);
     this.router.navigateByUrl('/Login');
 }
開發者ID:davidrensh,項目名稱:NG2Reward,代碼行數:7,代碼來源:app.ts

示例2: logout

 logout() {
     localStorage.removeItem('jwt');
     
     Login.messagesRef.unauth();
     this.ss.setlevel(0);
     this.router.navigateByUrl('/Login');
 }
開發者ID:davidrensh,項目名稱:NG2Reward,代碼行數:7,代碼來源:Logout.ts

示例3: ngOnInit

 ngOnInit() {
     if (!localStorage.getItem('jwt')) {
         this._router.navigateByUrl('/login');
         return;
     }
     this.getReports();
 }
開發者ID:WillBeebe,項目名稱:angular2-docker-demo,代碼行數:7,代碼來源:users.component.ts

示例4:

 data => {
     localStorage.setItem('token', data.token);
     localStorage.setItem('userId', data.userId);
     localStorage.setItem('firstname', data.firstname);
     localStorage.setItem('lastname', data.lastname);
     this._router.navigateByUrl('/');
 },
開發者ID:nbabusundaram,項目名稱:advantage,代碼行數:7,代碼來源:signin.component.ts

示例5: ngOnInit

 ngOnInit() {
     if (!localStorage.getItem('jwt')) {
         this._router.navigateByUrl('/login');
         return;
     }
     let id = this._routeParams.get('id');
     this.getUser(id);
 }
開發者ID:WillBeebe,項目名稱:angular2-docker-demo,代碼行數:8,代碼來源:user.component.ts

示例6: it

 it("should be able to navigate to Weather by URL", done => {
     router.navigateByUrl("/weather")
         .then(() => {
             expect(location.path()).toBe("/weather");
             done();
         })
         .catch(e => done.fail(e));
 });
開發者ID:mulenatic,項目名稱:angular2WithTypeScript,代碼行數:8,代碼來源:main.spec.ts

示例7: activate

 activate(instruction: ComponentInstruction) {
   var url = this.parentRouter.lastNavigationAttempt;
   if (!this.publicRoutes[url] && !this.userService.isConnected()) {
     // todo: redirect to Login, may be there a better way?
     this.parentRouter.navigateByUrl('/login');
   }
   return super.activate(instruction);
 }
開發者ID:feloy,項目名稱:var,代碼行數:8,代碼來源:loggedin-router-outlet.ts

示例8:

 data => {
     console.log(data);
     localStorage.setItem('token', data.token);
     localStorage.setItem('userId', data.userId);
     localStorage.setItem('firstname', data.firstname);
     localStorage.setItem('lastname', data.lastname);
     localStorage.setItem("emailId" , data.email);
     this._router.navigateByUrl('/');
 },
開發者ID:adhulappanavar,項目名稱:advantage,代碼行數:9,代碼來源:signin.component.ts

示例9: ngOnInit

  ngOnInit() {
    if(!this._coreService.isLoggedIn) this._router.navigateByUrl('/');
    else {
      this.cId = +this._routeParams.get('id');
			this.loadInfo();
			this.loadStorage();
			this.loadWorkers();
    }
  }
開發者ID:alexiusp,項目名稱:vc-manager,代碼行數:9,代碼來源:company.component.ts

示例10: activate

    activate(instruction: ComponentInstruction) {
	console.log('Outlet activate');
	var url = this.parentRouter.lastNavigationAttempt;
	console.log("url="+url);
	if (!this.publicRoutes[url] && !this._userService.isConnected()) {
	    // todo: redirect to Login, may be there a better way?
	    console.log(' no token => redirect to /login');
	    this.parentRouter.navigateByUrl('/login');
	}
	return super.activate(instruction);
    }
開發者ID:feloy,項目名稱:var,代碼行數:11,代碼來源:loggedin_router_outlet.ts


注:本文中的angular2/router.Router.navigateByUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。