簡體   English   中英

如何刷新<div>在 angular 中單擊按鈕內容更快?</div><div id="text_translate"><p> 我有一個具有一定價值的內容,單擊取消按鈕時,我需要刷新它並顯示新內容。 當我單擊取消按鈕時,舊內容會保留幾秒鍾,然后再更改為新內容。請告訴我如何更快地加載新內容而不會出現這種延遲。</p><pre> &lt;div&gt;Text&lt;/div&gt; &lt;button type="button" class="left-btn pull-right" (click)="reload()" data-dismiss="modal"&gt;cancel&lt;/button&gt; reload() { this.CommonService.GetDateTimeByTimeZone().subscribe(tz =&gt; { let ds: Input = { StartDate: moment(this.timezoneDate).format("YYYY-MM-DDT00:00:00.000[Z]"), EndDate: moment(this.timezoneDate).format("YYYY-MM-DDT23:59:59.999[Z]") } this.Dashboard(ds, false) }, error =&gt; { Swal.fire('', this.es.adminErrorMsgList[39].message, 'error') }); this.SelectedDate = ' '; }</pre></div>

[英]How to refresh <div> content faster on button click in angular?

我有一個具有一定價值的內容,單擊取消按鈕時,我需要刷新它並顯示新內容。 當我單擊取消按鈕時,舊內容會保留幾秒鍾,然后再更改為新內容。請告訴我如何更快地加載新內容而不會出現這種延遲。

<div>Text</div>

   <button type="button" class="left-btn pull-right" (click)="reload()" data-dismiss="modal">cancel</button>

 reload() {
    this.CommonService.GetDateTimeByTimeZone().subscribe(tz => {
      let ds: Input = {
        StartDate: moment(this.timezoneDate).format("YYYY-MM-DDT00:00:00.000[Z]"),
        EndDate: moment(this.timezoneDate).format("YYYY-MM-DDT23:59:59.999[Z]")
      }
      this.Dashboard(ds, false)
    }, error => {
      Swal.fire('', this.es.adminErrorMsgList[39].message, 'error')
    });
    this.SelectedDate = ' ';
  }

您實際上可以嘗試在點擊時重新加載數據

reload() {

   // do the reload here

    this.CommonService.GetDateTimeByTimeZone().subscribe(tz => {
      let ds: Input = {
        StartDate: moment(this.timezoneDate).format("YYYY-MM-DDT00:00:00.000[Z]"),
        EndDate: moment(this.timezoneDate).format("YYYY-MM-DDT23:59:59.999[Z]")
      }
      this.Dashboard(ds, false)
    }, error => {
      Swal.fire('', this.es.adminErrorMsgList[39].message, 'error')
    });
    this.SelectedDate = ' ';
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM