@angular/router#UrlSegmentGroup TypeScript Examples
The following examples show how to use
@angular/router#UrlSegmentGroup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: auth.guard.ts From barista with Apache License 2.0 | 6 votes |
checkLogin(url: string, isAdminRoute: boolean): boolean {
if (AuthService.isLoggedIn) {
if (isAdminRoute && !this.authService.isAdmin) {
this.router.navigate(['/projects/user']);
return false;
}
return true;
}
// Store the attempted URL for redirecting
const tree = this.router.parseUrl(url);
const primary: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
this.authService.redirectUrl = primary.toString();
this.authService.redirictParams = tree.queryParams;
// Navigate to the login page with extras
this.authService.logout();
return false;
}
Example #2
Source File: app-details.component.ts From scion-microfrontend-platform with Eclipse Public License 2.0 | 6 votes |
/**
* Filters {@link NavigationEnd} events matching the given route.
*/
function matchesRoute(router: Router, route: ActivatedRoute): MonoTypeOperatorFunction<NavigationEnd> {
return filter((navigationEnd: NavigationEnd): boolean => {
const rootUrlSegmentGroup = router.parseUrl(navigationEnd.url).root;
let urlSegmentGroupUnderTest: UrlSegmentGroup = null;
return route.snapshot.pathFromRoot.every(activatedRoute => {
urlSegmentGroupUnderTest = urlSegmentGroupUnderTest ? urlSegmentGroupUnderTest.children[activatedRoute.outlet] : rootUrlSegmentGroup;
return Arrays.isEqual(activatedRoute.url.map(segment => segment.toString()), urlSegmentGroupUnderTest.segments.map(segment => segment.toString()));
});
});
}