Why is this simple AngularJS ng-show not working?

后端 未结 7 688
旧时难觅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:30

    You need to use $timeout and inject it in your controller:

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

    Fiddle demo

    Edit: removed $scope.apply(); as @Salman suggested

提交回复
热议问题