title: How to upload a file using AngularJs like the traditional way
body: <p>I've been tried this for days. Assuming I have a form like following:</p>
  
  <pre><code>    &lt;form ng-submit="create()" class="form-horizontal" enctype="multipart/form-data"&gt;
        &lt;div class="control-group"&gt;
          &lt;label class="control-label"&gt;name : &lt;/label&gt;
          &lt;div class="controls"&gt;
            &lt;input type="text" class="input-xlarge" ng-model="message.title" /&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="control-group"&gt;
          &lt;label class="control-label"&gt;avatar : &lt;/label&gt;
          &lt;div class="controls"&gt;
            &lt;input type="file" ng-model="message.avatar" name="message[avatar]" /&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="well"&gt;
          &lt;input class="btn btn-large btn-primary" type="submit" value="建立資料" /&gt;
        &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I am using the carrierwave gem to handle the file upload behind the scene. My controller is like this:</p>
  
  <pre><code> $scope.create = function($scope.message){
     var deferred = $q.defer();
     $http({
         method: 'POST',
         url: '/resources/messages',
         data: $.param({message: message}),
         headers: {'Content-Type': 'multipart/form-data'}
     }).
       success(function(data, status, headers, config){
         deferred.resolve(data);
       }).
       error(function(data, status, headers, config){
         deferred.reject(status);
       });
     return deferred.promise;
    };
  </code></pre>
  
  <p>However it is not working. What I intend to do is create a form and upload everything like the old way, but the examples I found such as ng-upload, or like <a href="http://blog.brunoscopelliti.com/a-directive-to-manage-file-upload-in-an-angularjs-application">this post</a>, or <a href="http://blueimp.github.io/jQuery-File-Upload/">jquery file upload</a>, they don't suit my need. Is there any example or sample code for this purpose? Thank you. </p>