Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.
maxSS edited this page Sep 13, 2019 · 6 revisions
import { JamMenuModule } from 'ngx-jsonapi-material';

Selector: jam-menu

Properties
Name Value type Required Description
@Input() menu Menu true
@Input() source_data Array<Resource> true
@Output() selected EventEmitter<Object> true
Button properties
public id = 'string';
public attributes: {
    label: string
    icon?: string
    class?: string
    hidden?: boolean
    disabled?: boolean
    svg_icon?: string
    icon_font?: string
}

public addAttributes(attributes: MenuButtonAttributes): Button
public setAttributes(
        attribute: 'label' | 'icon' | 'class' | 'hidden' | 'disabled' | 'svg_icon' | 'icon_font',
        value: string | boolean
    ): Button
public show(): Button
public hide(): Button
public enable(): Button
public disable(): Button
Section properties
public id = 'string';
public data = Array<Button>
public findButton: (arg: string) => Button
public show(): Section
public hide(): Section

Example menu

import { Menu, Section, Button } from "ngx-jsonapi-material";

export const ITEMS_MENU: Menu = new Menu().addSections([
    new Section('Edición').addButtons([
        new Button('goToProductEdit').addAttributes({
            label: 'Editar producto',
            icon: 'mode_edit'
        }),
        new Button('goToUpdatePrices').addAttributes({
            label: 'Modificar precios',
            icon: 'icon-price_edit'
        })
    ]),
    new Section('Otros').addButtons([
        new Button('goToInventory').addAttributes({
            label: 'Inventario',
            icon: 'assignment'
        }),
        new Button('restoreProduct').addAttributes({
            label: 'Activar producto',
            icon: 'restore_from_trash'
        })
    ])
]);
<jam-menu
    [menu]="menu_options"
    (selected)="selectedOption($event)"
></jam-menu>
import { ITEMS_MENU } from './menu.model';
.
.
.
public menu: Menu = ITEMS_MENU;
.
.
.
public selectedOption(option: {[key: string]: any}): void {
    this[option](); // output: edit, newAuthor or removeRelationship...
}

private edit(): void { ... }

private newAuthor(); void { ... }

private removeRelationship():void { ... }
Clone this wiki locally