I'm displaying sanitized HTML in one my routes, which contains links to other parts of the router. However, clicking them results in the website reloading.
How do I pass the link to the router from outside the angular2 scope?
Example
article.component.ts
@Component({
selector: "article",
template: `<div [innerHTML]="content"></div>`, //html is not parsed by ng because its outside the scope
providers: []
})
export class ArticleComponent{
public content;
constructor(private sanitizer: DomSanitizer){
this.content = this.sanitizer.bypassSecurityTrustHtml(`<a href="/article/some_id">example link</a>`);
}
}
In my case, this.content is dynamic html downloaded via http request, which is why it must be sanitized.
app.routing.ts
const appRoutes: Routes = [
{
path: "article/:id",
component: ArticleComponent
}
]
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);