本文整理汇总了TypeScript中@ngrx/router.Router类的典型用法代码示例。如果您正苦于以下问题:TypeScript Router类的具体用法?TypeScript Router怎么用?TypeScript Router使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Router类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
.subscribe(action => {
const { path, query }: RouterMethodCall = action.payload;
switch (action.type) {
case routerActions.GO:
router.go(path, query);
break;
case routerActions.REPLACE:
router.replace(path, query);
break;
case routerActions.SEARCH:
router.search(query);
break;
case routerActions.BACK:
router.back();
break;
case routerActions.FORWARD:
router.forward();
break;
}
});
示例2: gotoQueryParams
// I navigate to the current URL with the given name-value pairs in the query-string.
// This method is designed to leave all other query-string parameters in place.
public gotoQueryParams( delta: { [key: string]: any } ) : void {
var parts = this.router.path().split( "?" );
var pathString = parts.shift();
var queryString = parts.shift();
var updatedQueryParams = parse( queryString );
for ( var key in delta ) {
if ( delta[ key ] === null ) {
delete( updatedQueryParams[ key ] );
} else {
updatedQueryParams[ key ] = delta[ key ];
}
}
this.router.go( pathString, updatedQueryParams );
}
示例3: gotoScreen
public gotoScreen( targetScreenId: number ) : void {
this.isShowingScreenBrowser = false;
var currentSection = this.router.path().split( /\//g ).pop();
this.router.go( `/console/project/${ this.projectId }/screen/${ targetScreenId }/${ currentSection }` );
}
示例4: persistFilter
// I persist the current filter to the URL (via a param-based navigation).
private persistFilter() : void {
this.router.search({
filter: this.filter
});
}
示例5: protectRoute
protectRoute(candidate: TraversalCandidate) {
if (!tokenNotExpired()) {
this.router.go('/login');
return Observable.of(false);
}
return Observable.of(true);
}
示例6:
return observable.catch((err, source) => {
if (err.status === 401 && !_.endsWith(err.url, 'authenticate')) {
this._router.go('/login');
return Observable.empty();
} else {
return Observable.throw(err);
}
});
示例7: protectRoute
protectRoute(candidate: TraversalCandidate) {
if (tokenNotExpired('auth_token')) {
return Observable.of(true);
} else {
this._router.go('/login');
return Observable.of(false);
}
}
示例8:
.map(res => {
if (res) {
return true;
} else {
this._router.replace(candidate.route.options.permission.redirectTo);
return false;
}
});
示例9: interceptError
private interceptError(error: Error) {
console.log('error', error);
if (error.message === 'No JWT present') {
console.log('no JWT, redirecting to login page');
this.router.go('/login');
return true;
}
return false;
}
示例10:
.map(inStore => {
if(inStore && inStore.length>0){
console.log("colleciton-exists.ts = inStore.length ="+inStore.length);
return true;
}else{
if((canidate.locationChange.path ==='/' ||
canidate.locationChange.path ==='') ){
console.log('colleciton-exists.ts = checkForAlblumCollection = canidate ', canidate)
console.log('colleciton-exists.ts = checkForAlblumCollection = this._router ', this._router)
this._router.go('/audioArtist/find')
}
return false;
}
});