如何正确地将参数传递给$ resource(...)。保存角度

时间:2018-02-19 14:10:29

标签: php angularjs session-variables

我正在开发angularJS应用程序,我需要使用$ resources并将$ _POSY值传递给php文件,然后我将值设置为$ _SESSION并结束php脚本。

这是我写的代码:

var setData = function(place) {
        // Angular $http() and then() both return promises themselves

        return $resource('./PHP/session/placeSession.php').
               save({ lastPlace: json }).
               $promise.then(function(res) {
                  console.log(res + "   " + json);
                }).catch(function (err) {
                  console.log(err);
               });
    };

这就是placeSession.php

<?php

  session_start();
  $_SESSION['lastPlace'] = $_POST['lastPlace'];
?>

是不是?如果我在控制台中显示它,则lastPlace中的值为:[object Object]。

0 个答案:

没有答案