Avoiding timeouts in Angular applications

后端 未结 2 949
长情又很酷
长情又很酷 2021-01-23 07:22

I have a problem that I was able to solve, using a timeout. This feels like a very bad practice that could lead to an unmaintainable mess, and I am looking for a better way to s

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-23 07:53

    scope.$apply() may help :

     $scope.fillAndSend = function() {
        $scope.model = 'fail';
        $scope.$apply();
        $scope.send();
        /* using a timeout works
        $timeout(function(){
            $scope.send();    
        },0);
        */
    }
    

提交回复
热议问题