|
9 | 9 | function IndexController($http) { |
10 | 10 | var vm = this |
11 | 11 |
|
12 | | - var cities = [ |
13 | | - { |
14 | | - name: 'Maringa', uf: 'PR', id: '500c709b-9504-462e-9b24-422852cac418' |
15 | | - }, |
16 | | - { |
17 | | - name: 'São Paulo', uf: 'SP', id: '6292ad1a-e80f-4642-9bb7-0c19f10db5b1' |
18 | | - }, |
19 | | - { |
20 | | - name: 'Apucarana', uf: 'PR', id: '7aebb3b6-c7ae-42aa-8d11-7b5ecc36b6f1' |
21 | | - }, |
22 | | - { |
23 | | - name: 'Londrina', uf: 'PR', id: '560c2ebe-b59f-44b2-99a3-19e9f148e401' |
24 | | - }, |
25 | | - { |
26 | | - name: 'Curitiba', uf: 'PR', id: '2b97cb57-46a3-4733-a69b-068f0a3b31ab' |
27 | | - } |
28 | | - ] |
29 | | - |
30 | | - vm.getDragons = getDragons |
31 | | - |
32 | | - function getDragons(search) { |
33 | | - |
34 | | - console.log('search {}', search) |
35 | | - |
36 | | - // não faça isso na vida real, isso é apenas para fins de teste |
37 | | - |
38 | | - var request = { |
39 | | - url: 'https://dragons-api.herokuapp.com/api/dragons', |
40 | | - method: 'GET', |
41 | | - } |
42 | | - |
43 | | - return $http(request).then(function (response) { |
44 | | - console.log('response {}', response.data.items); |
45 | | - return response.data.items |
| 12 | + vm.getLocation = getLocation |
| 13 | + |
| 14 | + function getLocation(search) { |
| 15 | + return $http.get('//maps.googleapis.com/maps/api/geocode/json', { |
| 16 | + params: { |
| 17 | + address: search, |
| 18 | + sensor: false |
| 19 | + } |
| 20 | + }).then(function (response) { |
| 21 | + console.log('response {}', response); |
| 22 | + return response.data.results |
46 | 23 | }) |
47 | | - |
48 | 24 | } |
49 | 25 |
|
50 | 26 | } |
|
0 commit comments