欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解決angular2 獲取到的數(shù)據(jù)無(wú)法實(shí)時(shí)更新的問(wèn)題

 更新時(shí)間:2018年08月31日 09:45:35   作者:網(wǎng)蟲(chóng)1325  
今天小編就為大家分享一篇解決angular2 獲取到的數(shù)據(jù)無(wú)法實(shí)時(shí)更新的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

今天在工作當(dāng)中碰到了個(gè)問(wèn)題,當(dāng)我點(diǎn)擊地圖上面的城市,從后臺(tái)獲取數(shù)據(jù)更新列表,明明后臺(tái)的數(shù)據(jù)已經(jīng)返回到前端,但是數(shù)據(jù)就是不能實(shí)時(shí)更新到頁(yè)面上,因?yàn)樵谧龅谝话娴臅r(shí)候是沒(méi)有這個(gè)問(wèn)題的,就感覺(jué)可能是自己調(diào)用后臺(tái)接口的時(shí)候順序出了問(wèn)題,結(jié)果一直鉆到死胡同里面去了,后來(lái)求助老大,終于把問(wèn)題解決了,現(xiàn)在記錄一下,以加深記憶。

問(wèn)題:點(diǎn)擊下面地圖上的城市,更新列表

 getPageList(){
    //this.postMapJson 輸入數(shù)據(jù)
    this.netUserAnalyzeService.getCityOrRegionOrgUserList(JSON.stringify(this.postMapJson))
    .then((res:any)=>{
      var list =res.data.list;
      
        var resList =this.netUserAnalyzeService.list(list);
        this.orgLists = resList;
        this.orgFirstId = res.data.list[0].organizationId;
        this.pageParams.totalItems = res.data.page["totalResult"];
      
      this.changeDetectorRef.markForCheck();
      this.changeDetectorRef.detectChanges();
    },error => this.errorMessage = error)
  }

上面代碼中 changeDetectorRef 所調(diào)用的具體的方法。

當(dāng)然在使用之前需要引入:

import {ChangeDetectorRef} from '@angular/core';
 constructor(
    private changeDetectorRef:ChangeDetectorRef
  ){}

以上這篇解決angular2 獲取到的數(shù)據(jù)無(wú)法實(shí)時(shí)更新的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論