我想检索从Angular函数发送到 PHP程序的对象. 这是我的观点: ion-viewion-content padding="true"div class="card" div class="item item-divider text-center" Authentification /div div class="item item-text-wrap text-center" f
这是我的观点:
<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(){ });