डाउनलोड पी.डी.एफ. ई-बुक्स
AJS - Services $timeout

$timeout service; ये Object; Javascript के window.setTimeout() Method जैसे होता है | ये window.setTimeout() method का wrapper होता है |


Example for $timeout Service in AngularJS

Example पर 5 seconds(5000 milliseconds) के बाद दूसरे text को display किया जाएगा |

Source Code :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>

<div ng-app="app" ng-controller="ctrl"> 
Change Text After 5 seconds : {{var}}
</div>

<script>
var myapp = angular.module('app', []);
myapp.controller('ctrl', function($scope, $timeout){
$scope.var = "Hello World";
var myFunc = function (){
	$scope.var = "Hiii ! Friends";
}
$timeout(myFunc, 5000);
});
</script>

</body>
</html>
Output :
Change Text After 5 seconds : {{var}}