alfresco-ng2-components/docs/core/context-menu.directive.md
Andy Stark e03f3a1a6b [ADF-3323] Fixed broken links in doc files (#3662)
* [ADF-3323] Fixed URL path to Typescript source files

* [ADF-3323] Fixed and checked broken links caused by previous bug
2018-08-14 15:42:45 +01:00

1.1 KiB

Added, Status, Last reviewed
Added Status Last reviewed
v2.0.0 Active 2018-04-10

Context Menu directive

Adds a context menu to a component.

Basic Usage

<my-component [context-menu]="menuItems"></my-component>
<context-menu-holder></context-menu-holder>
@Component({
    selector: 'my-component'
})
export class MyComponent implements OnInit {

    menuItems: any[];

    constructor() {
        this.menuItems = [
            { title: 'Item 1', subject: new Subject() },
            { title: 'Item 2', subject: new Subject() },
            { title: 'Item 3', subject: new Subject() }
        ];
    }

    ngOnInit() {
        this.menuItems.forEach(l => l.subject.subscribe(item => this.commandCallback(item)));
    }

    commandCallback(item) {
        alert(`Executing ${item.title} command.`);
    }

}

Class members

Properties

Name Type Default value Description
enabled boolean false Is the menu enabled?
links any[] Items for the menu.

Details

See Demo Shell or DocumentList implementation for more details and use cases.