I am facing an issue with a command I have, where I retrieve content from the server that includes HTML and links. The problem arises when displaying this data as the links do not work. Upon inspecting the page source, I noticed that "routerLink" is being transformed into "router link," which may be why it's not functioning correctly. Below is the code snippet:
Here is my class, noting that routerLink is in camelcase here:
export class TwoComponent implements OnInit {
data = '<a routerLink="/one">ONE</a>'; //this will actually come from backend server
constructor() { }
ngOnInit() {}
}
And my html:
<div [innerHTML]="data | bypassSecurity"></div>
Upon loading the page and viewing the source, the routerLink has now been converted to lowercase:
<a routerlink="/one">ONE</a>
Initially, I suspected the bypassSecurity pipe to be responsible but after checking its output, I observed that routerLink was still in camel case. It appears that the transformation happens elsewhere. Here is my bypassSecurity pipe for reference:
export class BypassSecurityPipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {}
transform(value): any {
return this.sanitized.bypassSecurityTrustHtml(value);
}
}
If you have any insights on why and where this lowercase transformation occurs, your advice would be greatly appreciated :)