Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e30fe93

Browse files
update example
1 parent 115b482 commit e30fe93

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

‎index.controller.js‎

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,18 @@
99
function IndexController($http) {
1010
var vm = this
1111

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
4623
})
47-
4824
}
4925

5026
}

‎index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</head>
1111
<body data-ng-controller="IndexController as vm">
1212

13-
<auto-complete model="vm.cidade" func="vm.getDragons" property="name" icon-prefix="textsms" label="olosco"></auto-complete>
13+
<auto-complete model="vm.location" func="vm.getLocation" property="formatted_address" label="Location"></auto-complete>
1414

1515
</body>
1616
<!-- bower:js -->

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /