0

I have a Menu in Syncfusion Angular. The Menu Item should navigate to an URL in new tab. It is opening in same tab by overriding the website. How to acheive this.

@ViewChild('sidebarMenuInstance')
  public sidebarMenuInstance: SidebarComponent;
  @ViewChild('menu')
  private menuObj: MenuComponent;
  public menuItems: MenuItemModel[] = [    
    {
      text: 'Menu Item',
      iconCss: 'icon',
      items: [
        {
          text: 'Link', iconCss: 'icon-picture icon', url: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',         
        }
      ],
    }
  ];

1 Answer 1

0

  private beforeItemRender(args: MenuEventArgs): void {
        if (args.item.url) {
            // To open url in blank page.
            args.element.getElementsByTagName('a')[0].setAttribute('target', '_blank');
        }

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.