Skip to content

Instantly share code, notes, and snippets.

@mort3za
Created May 1, 2016 15:16
Show Gist options
  • Save mort3za/9c537f2f9da3bc262c3932b77e62a5b8 to your computer and use it in GitHub Desktop.
Save mort3za/9c537f2f9da3bc262c3932b77e62a5b8 to your computer and use it in GitHub Desktop.
Send file along with other fields in Angularjs
// inside directive
function linkFunc(scope, element, attrs, ctrl) {
element.on('change', '.file-logo', function(event) {
ctrl.onFileSelect(event.target.files);
});
}
function Controller() {
var vm = this;
vm.onFileSelect = onFileSelect;
function onFileSelect($files) {
console.log($files);
logoFile = $files[0];
// angular.forEach($files, function (value, key) {
// formDataObject.append(key, value);
// });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment