Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngAutocomplete",
"version": "1.0.0",
"version": "1.0.1",
"main": "src/ngAutocomplete.js",
"dependencies": {
"angular": ">=1.2.0"
Expand Down
10 changes: 9 additions & 1 deletion src/ngAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ angular.module( "ngAutocomplete", [])
//options for autocomplete
var opts
var watchEnter = false

//convert options provided to opts
var initOpts = function() {

Expand Down Expand Up @@ -83,6 +84,7 @@ angular.module( "ngAutocomplete", [])
if (scope.gPlace == undefined) {
scope.gPlace = new google.maps.places.Autocomplete(element[0], {});
}

google.maps.event.addListener(scope.gPlace, 'place_changed', function() {
var result = scope.gPlace.getPlace();
if (result !== undefined) {
Expand Down Expand Up @@ -138,7 +140,7 @@ angular.module( "ngAutocomplete", [])
element.val(detailsResult.formatted_address);
element.unbind('focusout')
})

});
}
}
Expand All @@ -152,6 +154,12 @@ angular.module( "ngAutocomplete", [])
var location = controller.$viewValue;
element.val(location);
};

// Trigger query for any address present on the model when the autocomplete is initialized
if (scope.ngModel) {
var result = { name: scope.ngModel };
getPlace(result);
}

//watch options provided to directive
scope.watchOptions = function () {
Expand Down