diff --git a/src/ngAutocomplete.min.js b/src/ngAutocomplete.min.js new file mode 100644 index 0000000..ab768db --- /dev/null +++ b/src/ngAutocomplete.min.js @@ -0,0 +1 @@ +"use strict";angular.module("ngAutocomplete",[]).directive("ngAutocomplete",function(){return{require:"ngModel",scope:{ngModel:"=",options:"=?",details:"=?"},link:function(e,t,n,o){var s,a=!1,c=function(){s={},e.options&&(a=e.options.watchEnter!==!0?!1:!0,e.options.types?(s.types=[],s.types.push(e.options.types),e.gPlace.setTypes(s.types)):e.gPlace.setTypes([]),e.options.bounds?(s.bounds=e.options.bounds,e.gPlace.setBounds(s.bounds)):e.gPlace.setBounds(null),e.options.country?(s.componentRestrictions={country:e.options.country},e.gPlace.setComponentRestrictions(s.componentRestrictions)):e.gPlace.setComponentRestrictions(null))};void 0==e.gPlace&&(e.gPlace=new google.maps.places.Autocomplete(t[0],{})),google.maps.event.addListener(e.gPlace,"place_changed",function(){var n=e.gPlace.getPlace();void 0!==n&&(void 0!==n.address_components?e.$apply(function(){e.details=n,o.$setViewValue(t.val())}):a&&i(n))});var i=function(n){var s=new google.maps.places.AutocompleteService;n.name.length>0&&s.getPlacePredictions({input:n.name,offset:n.name.length},function(n,s){if(null==n||0==n.length)e.$apply(function(){e.details=null});else{var a=new google.maps.places.PlacesService(t[0]);a.getDetails({reference:n[0].reference},function(n,s){s==google.maps.GeocoderStatus.OK&&e.$apply(function(){o.$setViewValue(n.formatted_address),t.val(n.formatted_address),e.details=n;t.on("focusout",function(e){t.val(n.formatted_address),t.unbind("focusout")})})})}})};o.$render=function(){var e=o.$viewValue;t.val(e)},e.watchOptions=function(){return e.options},e.$watch(e.watchOptions,function(){c()},!0)}}});