How can i call a function from Directive? when the GetAllActivityActionDetails method gets called, function is not firing. contrller function :
function GetAllActivityActionDetails() {
alert("GetAllActivityActionDetails");
}
Directive is :
app.directive("bwUpload", ['$log', '$http', function ($log, $http) {
return {
scope: { project: "=", activity: "=", action: "=", document: "=" },
link: function (scope, element, attributes) {
element.bind("change", function (changeEvent) {
var reader = new FileReader();
reader.onload = function (loadEvent) {
$log.log('onload.byteLength: ' + loadEvent.target.result.byteLength);
scope.$apply(function () {
var p = 'project_id=' + scope.project._id + '&activity_id=' + scope.activity._id +
'&action_name=' + scope.action.name + '&document_id=' + scope.document._id
var config = {
url: 'baf/DocumentUpload?' + p,
method: 'POST',
headers: { 'Content-Type': 'application/octet-stream' },
data: new Uint8Array(loadEvent.target.result),
transformRequest: []
};
$http(config).then(
function (resp) {
var response = resp.data;
$log.log("DocumentUpload response (fileName, length): " + response.fileName + ", " + response.length);
alert('Document Uploded.');
//bwGlobals.refreshView()
alert(scope.activity._id);
//GetAllActivityActionDetails(scope.activity._id);
scope.$apply("GetAllActivityActionDetails()");
alert("GetAllActivityActionDetails");
},
function (errResponse) { alert(errResponse); }
);
});
}
reader.readAsArrayBuffer(changeEvent.target.files[0]);
});
}
}
}]);
i want to call GetAllActivityActionDetails()form directive but it is not working