Created
          May 14, 2013 11:03 
        
      - 
      
- 
        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
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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