Created
July 5, 2021 10:04
-
-
Save Purecaesar/968fed9f7e8a1096bc78c3ef21836b29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { OutletContext } from "@angular/router"; | |
export function getCurrentOutlet(contextsMap: Map<string, OutletContext>, component: any) { | |
const contextsArray = Array.from(contextsMap.values()); | |
while (contextsArray.length) { | |
const outlet = contextsArray.shift(); | |
if (outlet.route?.component === component) { | |
return outlet; | |
} | |
const childrenContexts = (outlet.children as any)?.contexts as Map<string, OutletContext>; | |
contextsArray.push(...Array.from(childrenContexts.values())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment