javascript - Angular.js - Clear Text box when Google Autocomplete event fires? -


i want clear textbox value when google map autocomplete event fires. new angularjs facing little difficulty. can help?

html -

<input ng-model="deploytext" id="search_execute" class="form-control" type="text" placeholder="enter locations"> 

js code inside controller function -

var autocomplete = new google.maps.places.autocomplete($("#search_execute")[0], {types: ['(cities)']});         google.maps.event.addlistener(autocomplete, 'place_changed', function() {                      var place = autocomplete.getplace();             angular.element(document.getelementbyid('execute_place')).append("<div style='float:left'>"+place.address_components[0].long_name+"</div>");              $scope.execute.push({latitude:place.geometry.location.lat(), longitude:place.geometry.location.lng()});              $scope.deploytext = "";  //here want clear text            }); 

you have use $scope.$apply() non angular component in order take change

like this

$scope.deploytext = "";  //here want clear text   $scope.$apply(); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -