<!DOCTYPE html>
<html ng-app="myApp">
<head lang="en">
<meta charset="UTF-8">
<script src="js/angular.js"></script>
<title></title>
</head>
<body>
<div ng-controller="myCtrl">
<button ng-click="getData()">
get请求
</button>
<ul>
<li ng-repeat="tmp in list">
{{"name is "+tmp.name+" age is "+tmp.age}}
</li>
</ul>
</div>
<script>
var app = angular.module('myApp', ['ng']);
app.controller('myCtrl',
function ($scope,$http) {
$scope.list = [];
$scope.getData = function () {
$http
.get('data/test.json')
.success(function (result) {
$scope.list = result;
})
.error(function () {
console.log(arguments);
})
}
})
</script>
</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-12
  • 2021-11-05
  • 2021-05-21
猜你喜欢
  • 2021-08-08
  • 2021-04-01
  • 2021-09-28
  • 2021-12-07
  • 2021-08-03
  • 2021-10-16
相关资源
相似解决方案