javascript - angular looses function argument from directive (?) -


i use directive (note: using jade template engine):

file-upload.uploadcontainer(complete_function="set_value()") 

the directive itself:

app.directive('fileupload', function() {    return {       restrict: 'e',       scope: {          complete_function: "&completefunction"       }, //the rest of directive 

this directive uses uploadservice angular service. need call complete_function in controller when upload finished.

uploadservice.onuploadcomplete(function(event) {           alert("ok");           console.log("upload completed");           url = event.target.response;           console.log(url);           $scope.complete_function(url);         }); 

in upload service can see url (which returning server) valid. proceed calling $scope.complete_function(url) looks this:

$scope.set_value = function(url) {     console.log("called");     console.log(url); 

i know function gets called because can see log "called" (and have debugged), whole chain works charm. however, reason, url undefinedin set_value()...why??? have isolated scopes , such? how correctly? tried putting complete_function="set_value(**url**) didn't either.

i found solution here: http://blog-it.hypoport.de/2013/11/06/passing-functions-to-angularjs-directives/

basically need provide map of variable(s)...


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -