Angular Data Binding Frozen Until I Move Map After Clicking Marker That Calls DirectionsService #1550
Description
In angular 1.4.7 I have a click that I'm adding to a markers tag in my template as so:
<ui-gmap-google-map ng-if="assessment.mapReady==true" center="assessment.map.center" pan="true"
zoom="assessment.map.zoom">
<ui-gmap-markers models="assessment.markers" coords="'self'" icon="'icon'" click="click">
</ui-gmap-marker>
</ui-gmap-markers>
</ui-gmap-google-map>
I'm adding them in as so:
_.each(vm.sites, function(site,index) {
vm.destinations.push((site.address.address1 || '') + ' ' + (site.address.address2 || '') + ' ' + (site.address.city || '') + ' ' + (site.address.province || '') + ' ' + (site.address.postalCode || '') + ' ' + (site.address.country || ''));
//build marker
var val= {idKey: index, latitude: site.address.latitude, longitude: site.address.longitude, title: site.name, icon:{url: 'assets/img/hospital-building.png'}, click: function() {selectSite(site);}};
val["id"]= index;
// add marker to markers
vm.markers.push(val);
});
They are adding fine. The click calls selectSite which simply builds origin/destination LatLng points and sends them to calculateDirections. It hits the standard directions service `googleMaps.DirectionsService(); Then stores the steps from the first route of the first leg as so
' vm.directionsSteps=response.routes[0].legs[0].steps;
Here is the whole function for reference.
function calculateDirections(origin, destination) {
var request = {
origin: origin,
destination: destination,
travelMode: vm.googleMaps.DirectionsTravelMode.DRIVING
};
vm.directionsService.route(request, function (response) {
if (response.status === vm.googleMaps.DirectionsStatus.OK) {
//set routes
vm.directionsSteps=response.routes[0].legs[0].steps;
console.log(vm.directionsSteps);
}
});
}
In my template I simply have an ng-repeat on a
tag printing out the directionsSteps that I've just updated in my controller.
<div id="directionsDiv" style="overflow-y: hidden; right:30px;">
<p ng-repeat="wayPoint in assessment.directionsSteps" .instructions>
{{wayPoint.instructions}}
</p>
</div>
That's it. Super basic. Very straight forward. The bug is that when I click my marker everything works fine. I log directionsSteps to the console and it has the updated values which have changed to the results from the google directions service.
But in my page my page databinding is frozen 'until' I grab and move the map or perform some other task that kicks off the dirty checking and updates my page with the recent information. Does anyone know what's going on?