本文整理匯總了TypeScript中angular2/router.Location.path方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Location.path方法的具體用法?TypeScript Location.path怎麽用?TypeScript Location.path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/router.Location
的用法示例。
在下文中一共展示了Location.path方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isSelected
isSelected(path) {
if(path === this.location.path()){
return true;
}
else if(path.length > 0){
return this.location.path().indexOf(path) > -1;
}
}
示例2: getLinkStyle
getLinkStyle(path) {
if(path === this.location.path()){
return true;
}
else if(path.length > 0){
return this.location.path().indexOf(path) > -1;
}
}
示例3: isActiveRoute
public isActiveRoute(route: string): boolean {
let path = this._location.path()
if (path == '/'+route) {
return true
} else {
return false
}
}
示例4: if
client.session.subscribe((auth: FirebaseAuthData) => {
router.recognize(location.path()).then((instruction: Instruction) => {
if (auth && isAuthComponent(instruction)) {
router.navigate(['/Dashboard']);
} else if (!auth && !isAuthComponent(instruction)) {
router.navigate(['/Auth', 'Login']);
}
});
});
示例5: constructor
constructor(txtFileDataService: TxtFileDataService, location: Location) {
this.location = location;
console.log(location.path())
txtFileDataService.loadPageTitle().subscribe((data) => {
this.pageTitle = data;
});
}
示例6: tryNavigateAfterReloading
/**
*
* @returns {Promise.<string>} returns the original location where the browser comes from
*/
public tryNavigateAfterReloading(): Promise<string> {
const locationPath = this._location.path();
return this.getChildRoute(locationPath)
.then((carrier: RouteInstruction)=> {
this._outstandingChildRoutingUrl = carrier.outstandingPath;
return this._router.navigateByInstruction(carrier.instruction);
})
.then(() => locationPath);
}
示例7:
.subscribe((isAuthorized: boolean) => {
if (isFirst)
return isFirst = false
const isLogin = /login/.test(this._location.path())
if (isAuthorized && !isLogin)
return
if (isLogin && isAuthorized)
this._router.navigate(['Home'])
else
this._router.navigate(['Login'])
})
示例8:
return state$ => state$.do(s => {
if (s.router.url !== location.path()) {
router.navigateByUrl(s.router.url);
}
})
示例9: getMode
getMode() {
return this._location.path() == '' ? 'categories' : this._location.path();
}
示例10:
this.router.subscribe(() => {
this.activeView = this.location.path();
});