Helper Functions: Add routerMatcher function in order to add more than one path in route configuration.
This commit is contained in:
parent
17212458eb
commit
ed20502959
|
@ -23,7 +23,11 @@ export class SideBarComponent implements AfterViewInit {
|
||||||
constructor(private route: ActivatedRoute, private router: Router, private sanitizer: DomSanitizer, private layoutService: LayoutService) {}
|
constructor(private route: ActivatedRoute, private router: Router, private sanitizer: DomSanitizer, private layoutService: LayoutService) {}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
UIkit.nav(this.nav.nativeElement).toggle(this.activeIndex, false);
|
if(this.nav) {
|
||||||
|
setTimeout(() => {
|
||||||
|
UIkit.nav(this.nav.nativeElement).toggle(this.activeIndex, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentRoute() {
|
get currentRoute() {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {UrlMatcher, UrlSegment} from "@angular/router";
|
||||||
|
|
||||||
export class HelperFunctions {
|
export class HelperFunctions {
|
||||||
|
|
||||||
public static scroll() {
|
public static scroll() {
|
||||||
|
@ -107,4 +109,37 @@ export class HelperFunctions {
|
||||||
public static swap(array: any[], from, to) {
|
public static swap(array: any[], from, to) {
|
||||||
array.splice(to, 0, array.splice(from, 1)[0]);
|
array.splice(to, 0, array.splice(from, 1)[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static routingMatcher:((paths: string[]) => UrlMatcher) = (paths: string[]) => {
|
||||||
|
return (segments) => {
|
||||||
|
const matchingPathIndex = paths.findIndex((path, index) => {
|
||||||
|
const pathSegments = path.split("/");
|
||||||
|
return segments.every((segment, i) =>
|
||||||
|
pathSegments.length > i && (
|
||||||
|
pathSegments[i].startsWith(":") ? true : segment.path.toLowerCase() === pathSegments[i].toLowerCase()));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (matchingPathIndex >= 0) {
|
||||||
|
const matchingPath = paths[matchingPathIndex];
|
||||||
|
|
||||||
|
const consumed: UrlSegment[] = [];
|
||||||
|
const params = {};
|
||||||
|
|
||||||
|
matchingPath.split("/").forEach((path, i) => {
|
||||||
|
consumed.push(segments[i]);
|
||||||
|
if (path.startsWith(":")) {
|
||||||
|
const param = path.substring(1);
|
||||||
|
params[param] = segments[i];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
consumed: consumed,
|
||||||
|
posParams: params
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
Component,
|
Component,
|
||||||
ContentChildren,
|
ContentChildren,
|
||||||
ElementRef,
|
ElementRef, Input,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
QueryList,
|
QueryList,
|
||||||
ViewEncapsulation
|
ViewEncapsulation
|
||||||
|
@ -27,6 +27,8 @@ import {THREE} from "@angular/cdk/keycodes";
|
||||||
})
|
})
|
||||||
export class TransitionGroupComponent implements AfterViewInit, OnDestroy {
|
export class TransitionGroupComponent implements AfterViewInit, OnDestroy {
|
||||||
@ContentChildren(TransitionGroupItemDirective) items: QueryList<TransitionGroupItemDirective>;
|
@ContentChildren(TransitionGroupItemDirective) items: QueryList<TransitionGroupItemDirective>;
|
||||||
|
@Input()
|
||||||
|
public id: string;
|
||||||
private disabled: boolean = false;
|
private disabled: boolean = false;
|
||||||
private subscription: Subscription;
|
private subscription: Subscription;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue