useRouteData
Generic types: | T |
Retrieves the value of the given
from the current or deeper routes.
See Also
Presentation
function useRouteData (
token: RouteDataToken <T>,
scope: "current" | "children",
): Signal <T | null>;
Returns
Signal <T | null>
-signal of value of the given token, or null
if such value is not defined. Navigation may change the value.
Parameters
Name | Type | Description |
---|---|---|
token |
| the target token to retrieve value of |
scope | "current" | "children" | "current": retrieves from the |
Example usage
export const NAV_STATUS = new RouteDataToken <NavStatus>("NAV_STATUS");
export const PAGE_ROUTES: Routes = [
{
path: "",
component: PageComponent,
data: compileRouteData ([
defineRouteData ({
token: NAV_STATUS,
value: NavStatus.Collapsed,
}),
]),
},
]
private navStatus = useRouteData (NAV_STATUS, "children");
<app-nav [status]="navStatus()" />