检索对象(PHP和ANGULARJS)

我想检索从Angular函数发送到PHP程序的对象.
这是我的观点:

<ion-view>
<ion-content padding="true">
<div class="card">
  <div class="item item-divider text-center">
    Authentification
  </div>
  <div class="item item-text-wrap text-center">
    <form>
      <div class="list">
        <label class="item item-input">
          <input type="text" placeholder="Nom d'utilisateur" ng-model="user.username">
        </label>

        <label class="item item-input">
          <input type="password" placeholder="mot de passe" ng-model="user.password">
        </label>


      </div>
    </form>

  </div>
  <div class="item item-divider text-center">
    <a  href="" class="button button-positive button-small" ng-click="logIn(user)">
      <i class="ionicons ion-android-share"></i>
      Identifiez moi, vite !
    </a>
    <a  href="" class="button button-energized button-small">
      <i class="ionicons ion-android-mail"></i>
      Mot de passe perdu !
    </a>
  </div>
</div>
<button class="button button-large button-full button-positive">
  je n'ai pas de compte
</button>

这是控制器:

'use strict';

app
.controller('homepageIndex',function ($scope) {
})
.controller('homepageLogin',function ($scope , userProvider) {
  $scope.user={};

  $scope.logIn = function (user) {
    console.log($scope.logIn);
    console.log($scope.user);
    userProvider.logIn(user);
  }


 })
 ;

这是我的userProvider.js

'use strict';

app.factory('userProvider', function ($rootScope , $http) {

  function logIn(user) {
    var url='http://127.0.0.1:100/suitecrm/service/rest.PHP';

    $http.post(url,user)
      .success(function (response) {
      console.log(response);
        console.log(url);

      });

  }

  return {
    logIn: logIn
  }
});

在我的文件rest.PHP中,我想检索包含用户名和密码的对象用户

$username =$_POST['username'];
$password =$_POST['password'];

这个方法不起作用我想知道如何在rest.PHP中检索用户名和密码
谢谢你的帮助.

解决方法:

请尝试以下代码.

var req = {
 method: 'POST',
 url: 'http://127.0.0.1:100/suitecrm/service/rest.PHP',
 data: { username: 'username', password:  'password' }
}

$http(req).then(function(){
   //Success
}, function(){

});

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...