-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (39 loc) · 1.14 KB
/
Copy pathscript.js
File metadata and controls
41 lines (39 loc) · 1.14 KB
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
var app = angular.module("myApp", []);
app.controller('myCtrl',
function ($scope, $http) {
$scope.onup = function (form) {
$scope.jokes = [];
var config = {
headers: {
'Accept': 'application/json'
}
};
console.log(form);
if (form != "") {
var url = "https://icanhazdadjoke.com/search?term=" + form;
$http.get(url, config).then(function (response) {
console.log(response);
// $scope.returnData = response.data;
$scope.results = response.data.results;
for (var key in $scope.results) {
if ($scope.results.hasOwnProperty(key)) {
console.log(($scope.results[key].joke));
$scope.jokes.push(($scope.results[key].joke));
}
}
});
}
}
$scope.onclick = function (button) {
var config = {
headers: {
'Accept': 'application/json'
}
};
var url = "https://icanhazdadjoke.com/";
$http.get(url, config).then(function (response) {
console.log(response);
$scope.randomJoke = response.data.joke;
});
}
})