菜鸟学堂
在线运行
源代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://edu.jb51.net/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <p>两秒后显示信息:</p> <h1>{{myHeader}}</h1> </div> <p>$timeout 访问在规定的毫秒数后执行指定函数。</p> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $timeout) { $scope.myHeader = "Hello World!"; $timeout(function () { $scope.myHeader = "How are you today?"; }, 2000); }); </script> </body> </html>
运行结果
在线运行
菜鸟学堂 edu.jb51.net