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

AngularJS timer (interval)

黄舟
Release: 2017-02-18 13:56:35
Original
1160 people have browsed it

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>
Copy after login


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)!


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template