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