作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有几个地方使用 $timeout 或 $interval 在 UI 中发生延迟。这是一个简化的示例:
Controller 代码 :
$timeout(function() {
$scope.showElement = true;
}, 10000);
<div id="myElement" ng-show="showElement"></div>
最佳答案
可以装修$timeout
和 $interval
覆盖提供给他们的延迟:
较低的等待时间.js
exports.module = function() {
angular.module('lowerWaitTimeDecorator', [])
.config(function($provide) {
$provide.decorator('$timeout', function($delegate) {
return function() {
// The second argument is the delay in ms
arguments[1] = arguments[1] / 10;
return $delegate.apply(this, arguments);
};
});
})
};
beforeAll(function() {
var lowerWaitTime = require('lower-wait-time');
browser.addMockModule('lowerWaitTimeDecorator', lowerWaitTime.module);
});
afterAll(function() {
browser.removeMockModule('lowerWaitTimeDecorator');
});
it('My-sped-up-test', function() {
});
关于angularjs - 模拟 Protractor 中的时间流逝?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31083521/
我是一名优秀的程序员,十分优秀!