javascript - How to pass variable to named function with angular $on? -
i have created following listener:
scope.$on('location', updatemap)
this worked great, updatemap needs take variable:
function updatemap(request){ ... }
i need pass variable request:
var request = { origin: origin, destination: new_destination, travelmode: google.maps.directionstravelmode[attrs.type], };
how pass variable request named function?
it's job of broadcast/emit event send arguments listeners, so:
scope.$broadcast('location', request); scope.$emit('location', request);
or if want call updatemap parameter need call within listener function:
scope.$on('location', function() { updatemap(request); });
Comments
Post a Comment