title: Angular $HTTP posting- dynamic URL and defining post
body: <p>I am trying to post a simple binary value (using $http) to a URL which si defined by a value in my HTML.</p>
  
  <p>I have successfully got the "card.id" being passed through (can see it in console log)</p>
  
  <pre><code>                &lt;td-card ng-repeat="card in cards"
                           on-destroy="cardDestroyed($index)"
                           on-swipe="cardSwiped($index)"
                           on-swipe-right="$parent.cardSwiped(card.id)"
                           on-swipe-left="$parent.cardSwiped(card.id)" &gt;
  </code></pre>
  
  <p>The data I want to post needs to be to a URL which has the card.id in it. </p>
  
  <p>How to I tell it what to post and how to trigger?</p>
  
  <pre><code>.controller('CardsCtrl', ['$scope', 'TDCardDelegate', 'cardsApi', '$http',
      function($scope, TDCardDelegate, cardsApi, $http) {
         console.log('CARDS CTRL');
          $scope.cards = [];
  
          $scope.onSwipeRight=function(product_id){console.log(product_id)}
          //Post for swipe right {'like':1, 'uid':21}
  
          $scope.onSwipeLeft=function(product_id){console.log(product_id)}
          //Post for swipe left {'like':0, 'uid':21}
  
               for(var i = 0; i &lt; 7; i++) {
                   cardsApi.getApiData()
                       .then(function (result) {
                           $scope.cards.unshift(result.data);
                           $scope.product_id = result.data.product_id;
                       })
                       .catch(function (err) {
                           $log.error(err);
                       });
               }
  
               $scope.$watchCollection('cards', function (newVal, oldVal) {
                   if(newVal &lt; oldVal) {
                       cardsApi.getApiData()
                           .then(function (result) {
                               $scope.cards.unshift(result.data);
                           })
                           .catch(function (err) {
                               console.log(err);
                           });
                   }
               });
  
               $scope.cardSwiped = function(card) {
           console.log('here');
           console.log(card);
         };
           //Removes card from top of stack
           $scope.cardDestroyed = function(index) {
               $scope.cards.splice(index, 1);
           };
  
           $scope.addCard = function() {
               var newCard = $scope.cards[$scope.cards.length];
               //newCard.id = Math.random();
               $scope.cards.push(angular.extend({}, newCard));
           };
  
          $scope.postRecordLikes = function(product_id){
              console.log(product_id)
              $http.post('http://test.com/analytic/' + product_id)
                  .then(function successCallback(product_id) {
                      // this callback will be called asynchronously
                      // when the response is available
                  }, function errorCallback(response) {
                      // called asynchronously if an error occurs
                      // or server returns response with an error status.
                  });
          };
      }
  ])
  </code></pre>