angularJs Demo1

前端之家收集整理的这篇文章主要介绍了angularJs Demo1前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html>
<html>
<head>
<Meta charset="utf-8">
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>


<div ng-app="myApp" ng-controller="myCtrl"> 
<h1 id="myh1">{{hello}}</h1>
</div>
<script>
var app = angular.module('myApp',[]);
app.controller('myCtrl',function($scope,$interval) {
  $scope.hello = "Hello world!";
  var flag = 0;
  $interval(function () {
	  if (flag===0){
      	$scope.hello = "I love you";
		  document.getElementById("myh1").style.color="red";
		  flag = 1;
	  }
	  else {
	  	$scope.hello = "Hello world!";
		  document.getElementById("myh1").style.color="blue";
		  flag = 0;
	  }
  },1000);
});
</script>


</body>
</html>



效果

+++++++++++++++++++

原文链接:https://www.f2er.com/angularjs/148576.html

猜你在找的Angularjs相关文章