<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>angularjs指令</title>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
<script src="jquery-2.1.3.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="angular.min.js"></script>
</head>
<body ng-app="kongwc" ng-controller="myCtrl">
<h1>{{name}}</h1>
<h1>{{num}}</h1>
</body>
<script>
var app = angular.module("kongwc",[]);
app.controller("myCtrl", function ($scope, $timeout, $interval) {
$scope.name = "小白牛";
$scope.num = 1;
var turnName = $timeout(function () {
$scope.name = "裂魂人";
},2000);
//$timeout.cancel(turnName); //取消定时器
var turnName1 = $interval(function () {
$scope.num += 1;
if($scope.num == 10){
$interval.cancel(turnName1); //取消定时器
}
},1000);
});
</script>
</html>