Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public ngOnInit(): void {
// if there is not config provided, then it will be automatically constructed based on the router state tree
if (typeof this.breadcrumbConfig === "undefined") {
this.breadcrumbConfig = { breadcrumbPaths: this.getPathsFromStateTree() };
// then refresh the config after every successful transition
this.deregisterTransitionHook = this.routingService.addTransitionHook(StarkRoutingTransitionHook.ON_SUCCESS, {}, () => {
this.breadcrumbConfig = { breadcrumbPaths: this.getPathsFromStateTree() };
});
}
}this.userService
.fetchUserProfile()
.pipe(filter((user?: StarkUser): user is StarkUser => typeof user !== "undefined"))
.subscribe((user: StarkUser) => {
this.user = user;
});
this.isMenuModeActive = this.breakpointObserver.isMatched([this.mediaQueryMdSm]);
this.breakpointObserver.observe([this.mediaQueryMdSm]).subscribe((state: BreakpointState) => {
this.isMenuModeActive = state.matches;
});
this.routingService.addTransitionHook(
StarkRoutingTransitionHook.ON_SUCCESS,
{
// match any state except the ones that are children of starkAppInit/starkAppExit or the Ui-Router's root state
to: (state?: StateObject): boolean => {
if (state && typeof state.name !== "undefined") {
const regexInitExitStateName: RegExp = new RegExp("(" + starkAppInitStateName + "|" + starkAppExitStateName + ")");
return !state.name.match(regexInitExitStateName) && !(state.abstract && state.name === "");
} else {
return true; // always match
}
}
},
(tran: Transition) => {
const hash: string = tran.targetState().params()["#"];
if (hash) {
this.scrollToHash(hash);
}public ngAfterViewInit(): void {
this.routingTransitionSuccessCallback = this.routingService.addTransitionHook(StarkRoutingTransitionHook.ON_SUCCESS, {}, () => {
if (this.isCurrentState()) {
this.isActive = true;
}
});
this.routingTransitionFinishCallback = this.routingService.addTransitionHook(StarkRoutingTransitionHook.ON_FINISH, {}, () => {
this.isActive = false;
});
}this.onOpenSidenav(event);
});
this.closeSidebarSubscription = this.sidebarService.closeSidebar$.subscribe(() => {
this.onCloseSidenavs();
});
this.toggleSidebarSubscription = this.sidebarService.toggleSidebar$.subscribe((event: StarkAppSidebarOpenEvent) => {
this.onToggleSidenav(event);
});
this.breakpointObserver.observe([this.mediaQueryGtLg]).subscribe((state: BreakpointState) => {
this.onObserveBreakpoints(state);
});
this.deregisterTransitionHook = this.routingService.addTransitionHook(StarkRoutingTransitionHook.ON_SUCCESS, {}, () => {
this.onSuccessfulTransition();
});
}