本文整理匯總了TypeScript中angular2/router.Router.recognize方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Router.recognize方法的具體用法?TypeScript Router.recognize怎麽用?TypeScript Router.recognize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/router.Router
的用法示例。
在下文中一共展示了Router.recognize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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']);
}
});
});
示例2: _getInstruction
private _getInstruction(url) {
this.router.recognize(url).then((ins) => {
if (ins) {
// Store the current route instruction
this._last = this._current;
this._current = ins;
}
});
}
示例3: recognizePathRecursive
private recognizePathRecursive(locationPath: string): Promise<Instruction> {
if (!locationPath) {
return Promise.reject<Instruction>('No instruction found.');
}
return this._router.recognize(locationPath)
.then(instruction => {
if (instruction === null) {
var newLocationPath = locationPath.slice(0, locationPath.lastIndexOf('/'));
return this.recognizePathRecursive(newLocationPath);
}
return instruction;
});
}
示例4:
_router.subscribe((url) => {
_router.recognize(url).then((instruction) => {
console.log(instruction);
});
});