1.代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="angular.js"></script>
</head>
<body>

<div ng-app="testapp" ng-controller="ctrl">
  <div ng-repeat="nmb in arr">
	{{nmb}}
  </div>
</div>

<script>
	var rootscope;
	var app = angular.module('testapp', []);
	app.controller('ctrl',function($scope,$rootScope,$timeout){

		rootscope=$rootScope;

		$rootScope.arr = [1,2,3,4];
		
		$timeout(function () {
			$rootScope.arr.push(5);
			$rootScope.$apply();

			console.log(rootscope.arr);
		}, 2000);

	});

	
</script>

</body>
</html>

2.结果

angularJs $timeout $rootscope 以及 $apply

angularJs $timeout $rootscope 以及 $apply

相关文章: