-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
73 lines (59 loc) · 2.29 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Error Catcher Custom Esli</title>
</head>
<body ng-app="customErrorCatcher" ng-controller="testCtrl">
<div>
<button ng-click="getItems()">Get Items</button>
<table border="1">
<tr ng-repeat="item in items">
<td>{{item.title}}</td>
<td>{{item.userId}}</td>
<td>{{item.id}}</td>
</tr>
</table>
</div>
<div>
<form ng-submit="postThis()" role="form" enctype="multipart/form-data">
<label>Title</label>
<input type="text" ng-model="formData.title" name="title" id="title">
<label>UserId</label>
<input type="number" ng-model="formData.userId" name="userId" id="userId">
<label>Body</label>
<textarea ng-model="formData.body" name="body" id="body"></textarea>
<br>
<button type="submit">Post</button>
</form>
</div>
<script src="node_modules/angular/angular.min.js"></script>
<script src="scripts/app.js"></script>
<script>
app.controller('testCtrl', function($scope, $http) {
$scope.getItems = function () {
$http.get('https://jsonplaceholder.typicode.com/todos').then(function (response) {
console.log(response)
$scope.items = responsssse.data
})
};
$scope.postThis = function () {
var formData = new FormData;
formData.append('title', $scope.formData.title);
formData.append('userId', $scope.formData.userId);
formData.append('body', $scope.formData.body);
console.log('my FormData', $scope.formData.title)
console.log('my FormData', $scope.formData.userId)
console.log('my FormData', $scope.formData.body)
$http.post('https://jsonplaceholder.typicode.com/posts', formData,{
headers:{
'Content-Type': undefined,
processData: false
}
}).then(response => response.json())
.then(json => console.log(json))
}
});
</script>
</body>
</html>