Home > Web Front-end > JS Tutorial > body text

Detailed explanation of $timeout usage code in AngularJS

小云云
Release: 2018-02-07 11:45:59
Original
2168 people have browsed it

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

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!

Related labels:
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