Skip to content

Commit

Permalink
add anchor scrolling / fragment navigation for serverHtml content
Browse files Browse the repository at this point in the history
  • Loading branch information
shauke committed Jan 13, 2020
1 parent 304d321 commit 3a4e6ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/core/directives/server-html.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export class ServerHtmlDirective implements AfterContentInit, AfterViewInit, OnD
}

if (cb && this.callbacks && typeof this.callbacks[cb] === 'function') {
// handle links with callback functions, e.g. <a callback="availableCallbackFunction">
this.callbacks[cb]();
} else if (href.startsWith('#')) {
// handle fragment links / anchor navigation
this.router.navigate([this.router.url.split('#')[0]], { fragment: href.replace('#', '') });
} else {
// otherwise handle as routerLink
this.router.navigateByUrl(href);
Expand Down

0 comments on commit 3a4e6ea

Please sign in to comment.