$apply

作者: 郑伟的菜园子 | 来源:发表于2016-08-23 18:16 被阅读11次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body ng-app="myApp" ng-controller="mainController">
        <p>{{a}}</p>
        <script src="angular.min.js"></script>
        <script>
            angular.module('myApp',[]).controller('mainController',function($scope){
                $scope.a = 100;
                setTimeout(function(){
                    $scope.$apply(function(){
                        $scope.a = 200;
                    });
                },500);
            });
        </script>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:$apply

          本文链接:https://www.haomeiwen.com/subject/hhdnsttx.html