本文整理汇总了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);
});
});