1. Problemhintergrund
Stellen Sie einen Timer ein, um die Zählvariable alle 1 Sekunde zu ändern
2. Implementierungsquellcode
<!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 🎜 >