您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

调试量角器到角度同步问题的规范方法

调试量角器到角度同步问题的规范方法

好的,这个问题引起了我的兴趣,因此我想出了一个程序化的解决方案来确定如何等待量角器:

var _injector = angular.element(document).injector();
var _$browser = _injector.get('$browser');
var _$http = _injector.get('$http');
var pendingTimeout = true;

//this is actually method that protractor is using while waiting to sync
//if callback is called immediately that means there are no $timeout or $http calls
_$browser.notifyWhenNoOutstandingRequests(function callback () {
  pendingTimeout = false
});

setTimeout(function () {
  //this is to differentiate between $http and timeouts from the "notifyWhenNoOutstandingRequests" method
  if (_$http.pendingRequests.length) {
    console.log('Outstanding $http requests', _$http.pendingRequests.length)
  } else if (pendingTimeout) {
    console.log('Outstanding timeout')
  } else {
    console.log('All fine in Angular, it has to be something else')
  }
}, 100)

在这里,在http://plnkr.co/edit/O0CkpnsnUuwEAV8I2Jil?p=preview中,您可以尝试超时和$ http调用,我的延迟端点将等待10秒才能解决调用,希望对您有所帮助为了你

其他 2022/1/1 18:15:24 有581人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶