来自净化HTML的Angular2路由器链接

来自净化HTML的Angular2路由器链接,angular,Angular,我正在我的一条路由中显示经过消毒的HTML,其中包含到路由器其他部分的链接。但是,单击它们会导致网站重新加载 如何从angular2范围外将链接传递到路由器 范例 article.component.ts @Component({ selector: "article", template: `<div [innerHTML]="content"></div>`, //html is not parsed by ng because its o

我正在我的一条路由中显示经过消毒的HTML,其中包含到路由器其他部分的链接。但是,单击它们会导致网站重新加载

如何从angular2范围外将链接传递到路由器

范例

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>`); 
    }

  }
const appRoutes: Routes = [
    {
        path: "article/:id",
        component: ArticleComponent
    }
]

export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

请显示代码。我添加了一些示例代码。它只是[innerHTML]=“sanitizedHTML”,其中sanitizedHTML包含常规href链接(因为[RouterLink]未被解析)。单击它们将重新加载页面,而不是通过路由器发送。我正在寻找一种简洁的方法来强制路由器处理这些链接。您只能使用
[innerHTML]
添加普通HTML。没有绑定,没有指令,没有组件,也没有其他特定于Angular2的内容。是的。我想尝试从ng范围以外的地方访问路由器,或者提出一些更好的建议。“从ng范围之外访问路由器”是非常模糊的。也许