I am trying to use Place Autocomplete using AngularJS, and I receive:
initAutocomplete is not a function
I searched for similar problems, nothing helped to solve the problem.
This is my code:
angular.module('myapp').controller('FirstCont', function ($scope, $http) {
console.log("OUT");
$scope.slctd_lng = 'SDF'
$scope.slct_att = 'SD'
window.initAutocomplete = function () {
console.log("entered INIT");
$scope.autocomplete = new google.maps.places.Autocomplete((document.getElementById('autocomplete')),{ types: ['geocode'] });
$scope.autocomplete.addListener('place_changed', $scocpe.fillInAddress);
}
$scope.fillInAddress = function () {
var place = $scope.autocomplete.getPlace();
}
$scope.geolocate = function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
$scope.autocomplete.setBounds(circle.getBounds());
});
}
}});
And in my html file, I included:
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDsMQs29oSTadTMQI8Qy-VudC4N-kPvCpU&libraries=places&callback=initAutocomplete"
async defer></script>
Note: I can see: (in the html file)
$scope.slctd_lng = 'SDF'
$scope.slct_att = 'SD'
but I did not receive 'OUT' in the console!!
Thanks