Home >Web Front-end >JS Tutorial >AngularJS timer (interval)

AngularJS timer (interval)

黄舟
黄舟Original
2017-02-18 13:56:351140browse

1. Problem background

Set a timer to change the count variable every 1 second


2. Implementation source code

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title> AngularJS之定时器(interval)</title>
		<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
		<script>
			var app = angular.module("inApp",[]);
			app.controller("inCon",function($scope,$interval){
				$scope.count = 0;
				$interval(function(){
					$scope.count++;
				},1000);
			});
		</script>
	</head>
	<body ng-app="inApp" ng-controller="inCon">
		<p>
			{{count}}
		</p>
	</body>
</html>


3. Implementation result

AngularJS timer (interval)

The above is the content of AngularJS timer (interval). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn