Is it possible to set the $ scope variable of the controller from outside the controller?
For example, if I have a controller:
app.controller('citySelectCtrl', ['$scope',function($scope){ }]);
And a function in a global scope that has an event handler. Now I want to set the $scope variable when this event happens. Is it possible? My global function:
function initAutocomplete() { autocomplete = new google.maps.places.Autocomplete( (document.getElementById('autocomplete')), { componentRestrictions: {'country': 'in'}, types: ['(cities)'] }); map = new google.maps.Map(document.getElementById('map'), { center: {lat: 22.5937, lng: 78.9629}, zoom: 5, minZoom: 5 }); } autocomplete.addListener('place_changed', function() { infowindow.close(); marker.setVisible(false); var place = autocomplete.getPlace(); if (!place.geometry) { window.alert("Autocomplete returned place contains no geometry"); return; }
source share