-
Notifications
You must be signed in to change notification settings - Fork 0
DynamicMenu
Alex Malkevich edited this page Feb 20, 2019
·
2 revisions
Will render menu based on provided route configuration.
You have to provide template(s) for pieces of menu.
ndm-dynamic-menu
- Captures template that will render each menu item
- Required
- Context:
interface DynamicMenuItemContext { /** Each computed route config */ $implicit: DynamicMenuRouteConfig; /** From each computed route config's `data.menu` prop */ item: DynamicMenuItem; }
Example:
<ndm-dynamic-menu>
<li *ndmDynamicMenuItem="let route; let item = item">
<a [routerLink]="route.fullUrl">{{ item.label }}</a>
<ndm-dynamic-menu-items></ndm-dynamic-menu-items>
</li>
</ndm-dynamic-menu>
- Captures template that will wrap menu items
- Optional, by default renders list of items without wrapping tags
- Context:
interface DynamicMenuWrapperContext { /** Reference to template with children items */ $implicit: TemplateRef<any>; /** Context that has to be passed along to TemplateRef */ ctx: any; /** Array of route configurations that will be rendered */ configs: DynamicMenuRouteConfig[]; }Types:
@angular/core
TemplateRef
,DynamicMenuRouteConfig
Example:
<ndm-dynamic-menu>
<ul *ndmDynamicMenuWrapper>
<ndm-dynamic-menu-items></ndm-dynamic-menu-items>
</ul>
</ndm-dynamic-menu>
This will usually contain toggling elements with icon like <button>
- Captures template that will render menu item whose config
renderAsToggle
set totrue
- Optional, be default renders
dynamicMenuItem
template anddynamicMenuWrapper
one after another- Context:
interface DynamicMenuToggleContext { /** Each computed route config */ $implicit: DynamicMenuRouteConfig; /** From each computed route config's `data.menu` prop */ item: DynamicMenuItem; /** Template that renders sub-level of menu */ tpl: TemplateRef<any>; /** Context that has to be passed along to TemplateRef */ ctx: any; /** Flag that helps to control visibility of children, `false` by default */ context = { opened: false }; }Types:
DynamicMenuRouteConfig
,DynamicMenuItem
,@angular/core
TemplateRef
Example:
<ndm-dynamic-menu>
<li
*ndmDynamicMenuToggle="
let item;
let route = route;
let ctx = context
"
>
<a [routerLink]="route.fullUrl">{{ item.label }}</a>
<i class="down" (click)="ctx.opened = !ctx.opened"></i>
<div class="group" *ngIf="ctx.opened">
<ndm-dynamic-menu-items></ndm-dynamic-menu-items>
</div>
</li>
</ndm-dynamic-menu>
This component will render sub-menu of current menu node if exist.