我只是一个初学者,所以不要评价我。
我已经看到很多使用$ timeout函数而没有任何时间(或时间= 1ms)的angularjs插件(指令/服务)。
例如:
scope.openGallery = function (i) {
if (typeof i !== undefined) {
scope.index = i;
showImage(scope.index);
}
scope.opened = true;
document.body.style.overflow = 'hidden';
/////*******Here*******/////
$timeout(function() {
var calculatedWidth = calculateThumbsWidth();
scope.thumbs_width = calculatedWidth.width;
$thumbnails.css({ width: calculatedWidth.width + 'px' });
$thumbwrapper.css({ width: calculatedWidth.visible_width + 'px' });
smartScroll(scope.index);
});
};
任何具体原因他们这样做或做它的好处是什么?
http://stackoverflow.com/questions/20610450/angulajs-angularjs-timeout-without-delay-parameters-reason –