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
undefined
in 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
Post a Comment