在Kendo for Angular中禁用打开上下文菜单

时间:2019-04-26 19:40:23

标签: angular kendo-ui kendo-ui-angular2

在此StackBlitz中,如果复选框为true,则打开上下文菜单。但是,如果它为假,则不应打开。有什么想法可以实现后者吗?

@Component({
    selector: 'my-app',
    template: `
        <div #target>
            Target
        </div>
        <kendo-contextmenu [target]="target" [items]="items">
        </kendo-contextmenu>

        Enable context menu <input type="checkbox" [(ngModel)]="open">
    `
})
export class AppComponent {
    public items: any[] = items;
    open = true;
}

2 个答案:

答案 0 :(得分:1)

上下文菜单上没有代码告诉它不显示。尝试向其中添加* ngIf =“ open”。

答案 1 :(得分:0)

有一个 popupOpen 事件:

https://www.telerik.com/kendo-angular-ui/components/menus/api/ContextMenuComponent/#toc-popupopen

您可以在事件回调中像这样取消事件:

crontab

我试图修复您的 stackblitz,但它不起作用。似乎您的 stackblitz 示例具有非常过时的 angular 和 kendo deps。 但它在这里有效:使用 Angular 11.2.6,@progress/kendo-angular-menu": "^3.0.0"。

相关问题