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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -