-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathhttpdemo.html
39 lines (39 loc) · 1.31 KB
/
httpdemo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<script src="Scripts/angular.js"></script>
<script>
var app= angular.module("DemoApp",[]);
app.controller("HomeController", function($scope, $http, $interval){
function GetTime() {
var now = new Date();
$scope.clock = now.toLocaleTimeString();
}
$interval(GetTime,1000);
$scope.products=[];
$http.get("products.json")
.then(function onsuccess(response){
$scope.status = response.status;
$scope.statustext = response.statusText;
$scope.products = response.data;
},
function onfailure(response){
$scope.status = response.status;
$scope.statustext = response.statusText;
$scope.products = [];
})
})
</script>
</head>
<body ng-app="DemoApp" ng-controller="HomeController">
<h2>{{clock}}</h2>
<dl>
<dt>Status Code</dt>
<dd>{{status}}</dd>
<dt>Status Text</dt>
<dd>{{statustext}}</dd>
<dt>Data</dt>
<dd>{{products | json}}</dd>
</dl>
</body>
</html>