Instead of [routerLink]="[currentURL]" write: [routerLink]="[currentUrl? currentUrl.split('#')[0] : '']" and it will work all the time