Why is this simple AngularJS ng-show not working?

后端 未结 7 673
旧时难觅i
旧时难觅i 2020-12-13 06:10

I cannot figure out why my simple AngularJS app not working as intended. \"Loading...\" is supposed to be hidden, and \"Done!\" should be shown after 1 second.

html:

7条回答
  •  [愿得一人]
    2020-12-13 06:28

    You want to use apply() function to stop loading message.

    Check this Demo jsFiddle**.

    JavaScript:

    function TestCtrl($scope) {
        $scope.loading = true;
        setTimeout(function () {
            $scope.$apply(function(){
                $scope.loading = false;
            });
        }, 1000);
    }
    

    Hope this would be help you!

提交回复
热议问题