Angular2 uses navigate for route hopping, and the ngoninit cycle function is not triggered for the new route.

Jump method: _ this represents the component instance

      _this.router.navigate(["/analysis/examdetail"],
        {
          queryParams: _this.params
        });

in the new route:

  constructor(private route: ActivatedRoute, private mrequest: MrequestService, public changeDetectorRef: ChangeDetectorRef) {
    this.route.queryParams.subscribe(params => {
      console.log(params);
      this.e_id = params.e_id;
      this.p_id = params.p_id;
      this.endtype = params.endtype;
    });
    this.isIOS = mrequest.isIOSPlatform();
    console.log(this.endtype);
    this.getExamDetail();

  }

  ngOnInit() {
  console.log(2222);
  }
The jump on the

page is done by clicking on the echarts bar chart

    this.echartsIntance.on("click", function(params) {
      // console.log(params);
      const dataIndex = params.dataIndex;
      // console.log(_this.examId);
      _this.params["e_id"] = _this.examId[dataIndex];
      _this.params["p_id"] = _this.paperId[dataIndex];
      _this.params.cid = _this.classIdList[dataIndex];
      // console.log(_this.params);
      _this.router.navigate(["/analysis/examdetail"],
        {
          queryParams: _this.params
        });
    });

is it suspected that the jump angular2 in echarts cannot be detected? Is there any solution? The code in the
constructor can be executed, but the data in it cannot be rendered to the page, and the console cannot print the information in the ngoninit.

Mar.10,2021

you can try to capture route jump events in the component where router-outlet is located, and then update the contents via ChangeDetectorRef
I'm not sure if it's appropriate, but it works on my side


so ok

constructor(private  router: Router) {
    this.router.routeReuseStrategy.shouldReuseRoute = function() {
        return false;
    };
}
Menu