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
The above is the content of AngularJS timer (interval). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!