title: AngularJS/Rails $http.post data field name as variable
body: <p>I am trying to send some data from angular directive to rails controller using POST method. I wonder if it is possible to have data field name as variable. Example: </p>
  
  <pre><code>   var URL = null;
     var fieldName = null;
  
     if(something) {
       URL = ...;
       fieldName = ...;
     } else {
       URL = ...;
       fieldName = ...;
     }
  
     $http({
       url: URL,
       method: 'POST',
       data: { fieldName : c.$modelValue}
     })
  </code></pre>
  
  <p>Now my POST parameters are: "fieldName" => "(correct value from c.$modelValue)". I want field name to be fieldName value. Thank you in advance.</p>