单击routerLink时,Angular未重新加载组件

时间:2019-11-29 12:29:44

标签: angular angular6 angular2-routing

当我调用click事件时,我无法重新加载组件。我尝试了以下代码

 (dealCode,periodName) => {

    let url:any='/valuation;dealcode=J9PPR;fundPeriod=2019Q3;useDefault=true';
    this.router.navigateByUrl('/dummy', { skipLocationChange: true });
    setTimeout(() =>this.router.navigate([url]));
  }

1 个答案:

答案 0 :(得分:0)

Angular正在执行url编码,您必须告诉他信任您

import { DomSanitizer } from '@angular/platform-browser';
constructor(
    private _sanitzer: DomSanitizer
) { }

您的功能

(dealCode,periodName) => {

    let url:any='/valuation;dealcode=J9PPR;fundPeriod=2019Q3;useDefault=true';
    this.router.navigateByUrl('/dummy', { skipLocationChange: true });
    const safeUrl = this._sanitzer.bypassSecurityTrustUrl(url);

    setTimeout(() =>this.router.navigate([safeUrl]));
  }