本文整理匯總了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');
}
示例2: logout
logout() {
localStorage.removeItem('jwt');
Login.messagesRef.unauth();
this.ss.setlevel(0);
this.router.navigateByUrl('/Login');
}
示例3: ngOnInit
ngOnInit() {
if (!localStorage.getItem('jwt')) {
this._router.navigateByUrl('/login');
return;
}
this.getReports();
}
示例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('/');
},
示例5: ngOnInit
ngOnInit() {
if (!localStorage.getItem('jwt')) {
this._router.navigateByUrl('/login');
return;
}
let id = this._routeParams.get('id');
this.getUser(id);
}
示例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));
});
示例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);
}
示例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('/');
},
示例9: ngOnInit
ngOnInit() {
if(!this._coreService.isLoggedIn) this._router.navigateByUrl('/');
else {
this.cId = +this._routeParams.get('id');
this.loadInfo();
this.loadStorage();
this.loadWorkers();
}
}
示例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);
}