angularjs $timeout 没有延迟参数的原因 [英] angularjs $timeout without delay parameters reason

查看:23
本文介绍了angularjs $timeout 没有延迟参数的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一些脚本中我可以找到例如

In a few script I can find for instance

$timeout(function () {
    $scope.my = 1;            
});

而不仅仅是

$scope.my = 1;

立即调用 $timeout 的目的是什么?

What's the purpose to call $timeout without delay?

推荐答案

这是一个 hack.:) 但通常的目的是等到 $digest 循环结束,然后将 $scope.my 设置为 1.在所有监视完成后调用超时.

This is a hack. :) But usually the intention is to wait until the end of the $digest cycle and then set $scope.my to 1. Timeouts are called after all watches are done.

这篇关于angularjs $timeout 没有延迟参数的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆