如何使用php和angular js在http上发布ngCart结账按钮


How can i post the ngCart checkout button on http using php and angular js?

我不知道如何将我的数据发布到新的php页面中,这是我的代码:

<ngcart-checkout service="http" settings="{ url:'./checkout.php' }">Checkout </ngcart-checkout>

但是ngCart文档中的原始代码是

<ngcart-checkout service="http" settings="{ url:'/checkout' }"></ngcart-checkout>

ngcart结账代码是

<button class="btn btn-primary" ng-click="checkout()" ng-disabled="!ngCart.getTotalItems()" ng-transclude>Checkout</button>

但它并没有将我重定向到checkout.php,所以我转到ngcart.js,使用http-post结账的代码是

   .service('ngCart.fulfilment.http', ['$http', 'ngCart', function($http,        ngCart){
     this.checkout = function(settings){
         return $http.post(settings.url,
             {data:ngCart.toObject()})
     }
  }])

所以我的问题又是如何将我的签出按钮重定向到checkout.php,以及如何使用http-post将这些项目发布到checkoutphp?

我想你可能正在你的ngcart.js文件中寻找这样的东西

    <script>
    .service('ngCart.fulfilment.log', ['$http', 'ngCart', function($http, ngCart){
    this.checkout = function(settings){
        //var item_data = ngCart['$cart']['items'], message;
        //return $http.post('checkout.php',
        //    {data:item_data});
        var postData = 'item_data='+JSON.stringify(ngCart['$cart']['items']);
        $http({
            method : 'POST',
            url : 'checkout.php',
            data: postData,
            headers : {'Content-Type': 'application/x-www-form-urlencoded'}
        }).success(function(res){
            console.log(res);
        }).error(function(error){
            console.log(error);
        });
    }
}])</script>