【问题标题】:settimeout issue on iOS devicesiOS设备上的settimeout问题
【发布时间】:2016-06-07 14:49:51
【问题描述】:

以下超时功能不适用于 iOS 设备。 settimeout 功能是否在 iOS 设备上不起作用? 下面的代码有什么遗漏吗?

_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. typescript中的方法怎么写?

【问题讨论】:

  • 我怎样才能结束这个问题?

标签: angularjs mobile-safari settimeout


【解决方案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()
        });

【讨论】:

  • 语句执行但没有效果。
  • docs.angularjs.org/api/ng/service/$timeout,我认为第二个参数 true 运行应用
  • @LearnForever 如果语句确实运行但没有效果,则将应用放入.then。我已经更新了答案
猜你喜欢
  • 1970-01-01
  • 2011-09-07
  • 2013-08-19
  • 1970-01-01
  • 2019-10-08
  • 2021-06-27
  • 2017-12-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多