2016-02-25 55 views
0

下面的超時功能在iOS設備上不起作用。 是settimeout函數不適用於iOS設備? 下面的代碼中是否有缺少的東西?iOS設備上的settimeout問題

_timeoutService: ng.ITimeoutService 



this._timeoutService(1200, true).then(() => { 
      //below statement does not have any effect on iOS devices 
      // enable my angular material control 
      // set some text in an angular material input element 
      this.supportEmailCtrlDisabled = false; 
     }); 

我碰到過這個帖子https://stackoverflow.com/a/10991974/5252545。看起來像一個類似的問題。但不知道 - 1.如果這解決了我的問題? 2.什麼是「綁定」方法? 3.如何在打字稿中編寫方法?

+0

如何關閉這個問題? – LearnForever

回答

1

//下面的語句沒有在iOS設備上的任何影響

懷疑問題是越往上調用鏈。該功能可能是從外部呼叫$apply這意味着then不會觸發。

可能的解決

this._timeoutService(1200, true).then(() => { 
      //below statement does not have any effect on iOS devices 
      // enable my angular material control 
      // set some text in an angular material input element 
      this.supportEmailCtrlDisabled = false; 
      $scope.$apply() 
     }); 
+0

聲明確實執行,但不起作用。 – LearnForever

+0

https://docs.angularjs.org/api/ng/service/$timeout,我認爲第二個參數true運行apply – LearnForever

+0

@LearnForever,如果語句沒有運行,但沒有效果,則將apply放入'.then '。我已經更新了答案 – basarat