I create component dynamically with:
createComponent(componentType, {
environmentInjector: this.appRef.injector,
elementInjector: parentComponent.injector
});
The template looks like this:
<a [routerLink]="'./'" [fragment]="myFragment"</a>
On link click I want it to scroll to the element. The problem is that the link generated looks like this:
http://localhost:4200/#myFragment
instead of:
http://localhost:4200/someUrl/otherPartofUrl/#myFragment
The url is being overwritten. In components that are not created dynamically it works fine. Is there any way I can achieve that?