-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelter.html
120 lines (91 loc) · 2.86 KB
/
shelter.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Shelter</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<style type="text/css">
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="formCtrl">
<form>
<h1>Contact</h1>
Name: <input type="text" n1g-model="shelter.shelterName"/>
<!-- Phone Number: <input type="text" ng-model="shelter.phone"> -->
Size: <input type="text" ng-model="shelter.size"/>
Available Space<input type="number" ng-model="shelter.availableSpace"/>
Email: <input type="email" ng-model="shelter.email"/>
<!-- Address: <input type="text" ng-model="shelter.address"/> -->
WaitList: <input type="number" ng-model="shelter.waitlist"/>
Service: <input type="text" ng-model="shelter.service"/>
Password: <input type="password" ng-model="shelter.password">
<button ng-click="myFunction()">Print Json</button>
<button ng-click="sendData()">Send Data</button>
<button ng-click="getData()">Get Data()</button>
</form>
<div>
<!-- sample for rendering list -->
<ul>
<li ng-repeat="x in users ">
{{! x.FirstName + ', ' + x.LastName + ',' + x.SSN }}
</li>
</ul>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('formCtrl', function($scope,$http) {
$scope.shelter = {
"isShelter" : "1"
};
//see how data is formatted as json automatically
$scope.myFunction = function() {
console.log($scope.shelter);
}
$scope.userid = {
'userid':"25d55ad283aa400af464c76d713c07ad"
}
// sample for sending data to sever
$scope.sendData = function() {
$http.post('http://localhost:8000/data/get', $scope.userid)
.then(function(response){
//success callback
$scope.users = response.data.result
}, function(){
//failure callback
console.log("send failure");
});
}
// sample for getting data from server
$scope.getData = function(){
$http.get("http://localhost:8000/activated/7096170593576ceacbfe8da8aec36")
.then(function(response) {
//process data
$scope.response = response.data;
if ($scope.response.result == 'fail'){
console.log($scope.response.reason)
} else {
//$scope.user = response.data
}
});
}
//dummy data
// $scope.user = {
// 'email': '[email protected]',
// 'username' : "wanran",
// 'people': [
// {name:'Jani',country:'Norway'},
// {name:'Carl',country:'Sweden'},
// {name:'Margareth',country:'England'},
// {name:'Hege',country:'Norway'},
// {name:'Joe',country:'Denmark'},
// {name:'Gustav',country:'Sweden'},
// {name:'Birgit',country:'Denmark'},
// {name:'Mary',country:'England'},
// {name:'Kai',country:'Norway'}
// ]
// };
});
</script>
</body>