Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maowug/5575172 to your computer and use it in GitHub Desktop.
Save maowug/5575172 to your computer and use it in GitHub Desktop.
use jq-file-upload to post a 'form' without file? why not $http
getRNIAapp.directive('formupload',function(){
return {
restrict:'A',
scope:{
done:'&',
rnia:'='
},
link: function (scope,element,attrs){
var optionsObj={
dataType:'json'
};
//if have done attribute in the directive
if(scope.done){
// done in optionsObj is a success callback function
optionsObj.done=function(e,data){
scope.$apply(function(){
//event and object
scope.done({e:e,data:data});
});
};
}
// fileupload: widget initialization!
// Usually, file uploads are invoked by selecting or dropping
element.fileupload(optionsObj);
//imp! no (scope,element,attrs)
scope.submitRNIA = function(){
//todo:
optionsObj.formData=attrs.rnia;
element.fileupload('add',{files:[]});
};
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment