<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="libs/angular.min.js"></script>
<script>
var app=angular.module("gaoyn",[]);
var i=5;
app.controller("democ",["$scope","$timeout","$interval",function($scope,$timeout,$interval){
var timer= $interval(function(){
$scope.date=new Date();
},1000); //1s执行一次
$scope.stop=function(){
//让计时器停止计时
$interval.cancel(timer);
}
$timeout(function(){
console.log("砰砰 爆炸......");
},5000); //5s以后,执行爆炸操作
}]);
</script>
</head>
<body ng-app="gaoyn" ng-controller="democ">
{{date|date: 'yyyy-MM-dd hh:mm:ss'}}
<input ng-click="stop()" value="停止" type="button" />
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="libs/angular.min.js"></script>
<script>
var app=angular.module("gaoyn",[]);
var i=5;
app.controller("democ",["$scope","$timeout","$interval",function($scope,$timeout,$interval){
var timer= $interval(function(){
$scope.date=new Date();
},1000); //1s执行一次
$scope.stop=function(){
//让计时器停止计时
$interval.cancel(timer);
}
$timeout(function(){
console.log("砰砰 爆炸......");
},5000); //5s以后,执行爆炸操作
}]);
</script>
</head>
<body ng-app="gaoyn" ng-controller="democ">
{{date|date: 'yyyy-MM-dd hh:mm:ss'}}
<input ng-click="stop()" value="停止" type="button" />
</body>
</html>