I have a single page application and using RouterLink in anchor tag() to navigate to other pages without refresh.
<ul class="menu">
<li *ngIf="isContain(adminFilterMenuItems, 'Setup')">
<a id="NavSetupButton" routerLink="/setup">
<img alt="Setup" src="./assets/images/Setup.png" />
</a>
</li>
</ul>
I have the requirement to disable a few options on right click such as "Open in a new tab", "Open in a new window" etc, not disable entire context menu, I need the context menu.
I have observed that when I do not use RouterLink and implement other logic to navigate, I do not see those options on right click, which I want. But I am using RouterLink and don't want to mess with entire application for such a requirement.
Is there any way to disable a few options of context menu on right click while using RouterLink for navigation?
I found a workaround which works for me. Instead of using RouterLink, I called the click event and wrote a method "navigateTo", so this click event will call my "navigateTo" method which will do the job of page navigation.
HTML File
<ul class="menu">
<li *ngIf="isContain(adminFilterMenuItems, 'Setup')">
<a id="NavSetupButton" (click)="navigateTo('/setup')">
<img alt="Setup" src="./assets/images/Setup.png" />
</a>
</li>
</ul>
component.ts
navigateTo(component) {
this.router.navigate([component]);
}