<!DOCTYPE HTML> <html ng-app> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script src="angular.min.js"></script> <script> function Aaa($scope,$timeout){ $scope.name = ‘hello‘; setTimeout(function(){ $scope.$apply(function(){ $scope.name = ‘hi‘; }); },2000); //下面种方式,可以实现定时改变数据 /*$timeout(function(){ $scope.name = ‘hi‘; },2000);*/ } </script> </head> <body> <div ng-controller="Aaa" ng-click="show()"> <p>{{name}}</p> </div> </body> </html>
时间: 2024-10-12 18:38:58