Home >Web Front-end >JS Tutorial >Detailed explanation of $timeout usage code in AngularJS
This article mainly introduces the $timeout service sample code of AngularJS to you. Friends who need it can refer to it. I hope it can help everyone.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="../js/angular.js" ></script> <script> var app=angular.module("myApp",[]); app.controller("myCtrl",function($scope,$timeout){ //获取当前系统的时间对象 $scope.name="战三"; //设置定时器,每一秒调获得以下系统时间,复制给$scope.time $timeout(function(){ $scope.name="李四"; },3000); }); </script> </head> <body ng-app="myApp" ng-controller="myCtrl"> <p>{{name}}</p> </body> </html>
Related recommendations:
AngularJS dirty checking mechanism and the wonderful use of $timeout
The above is the detailed content of Detailed explanation of $timeout usage code in AngularJS. For more information, please follow other related articles on the PHP Chinese website!