在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ angular2 使用navigate進(jìn)行路由跳轉(zhuǎn),到新路由沒有觸發(fā)ngonin

angular2 使用navigate進(jìn)行路由跳轉(zhuǎn),到新路由沒有觸發(fā)ngoninit周期函數(shù)。

跳轉(zhuǎn)方法:_this代表組件實(shí)例

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

在新路由:

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

頁面中的跳轉(zhuǎn)是點(diǎn)擊echarts柱狀圖進(jìn)行跳轉(zhuǎn)的

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

懷疑是不是echarts中的跳轉(zhuǎn)angular2檢測(cè)不到?有什么解決辦法呢?
構(gòu)造器中的代碼可以執(zhí)行,但是其中的數(shù)據(jù)不能渲染到頁面中,控制臺(tái)打印不出ngoninit中的信息。

回答
編輯回答
悶騷型

你可以嘗試在router-outlet所在的組件捕獲路由跳轉(zhuǎn)事件,然后通過ChangeDetectorRef更新里面的內(nèi)容
不敢說合不合適 但是我這邊是湊效了

2018年5月12日 04:58