How to change value after delay by using angularjs?

后端 未结 2 2071
清歌不尽
清歌不尽 2020-12-13 12:40

I created basic application based on angularjs

HTML:

2条回答
  •  情书的邮戳
    2020-12-13 13:42

    Try using: $timeout

    Angular's wrapper for window.setTimeout. The fn function is wrapped into a try/catch block and delegates any exceptions to $exceptionHandler service.

    $timeout(fn[, delay][, invokeApply]);

    Updated Fiddle

    JavaScript

    var app = angular.module('miniapp', []);
    
    function Ctrl($scope, $timeout) {  
         $scope.val = false;
         $timeout(function(){$scope.val = true}, 3000);       
    } 
    

提交回复
热议问题