使用setTimeout更改范围属性

让我们。

为什么它不工作,设置$scope.blured在该setTimeout()(模拟帖子及回复)?

柱塞

$scope.bluryLines = function(value) {
    $scope.blured = true;

    if (value === '' || value === undefined) {
        console.log('value is empty');
    } else {
        console.log(value);
    }

    //faking a post
    setTimeout(function() {
        $scope.blured = false;
        console.log('log');
    }, 1000);
};

按下按钮可立即将其清除。

$scope.removeOverlay = function() {
    $scope.blured = false;
};
汉斯马德

setTimeout没有摘要。请改用角度$timeout服务。

app.controller('MainCtrl', function($scope, $timeout) {

    $scope.bluryLines = function(value) {
        $scope.blured = true;

        //faking a post
        $timeout(function() {
            $scope.blured = false;
        }, 1000);
    };

});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章