首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJs邮政法

AngularJs邮政法
EN

Stack Overflow用户
提问于 2016-03-18 16:33:53
回答 1查看 39关注 0票数 1

控制器

代码语言:javascript
复制
).controller('LoginController',
                         [
                           '$scope',
                            'dataService',
                            '$location',
                            '$window',
                    function ($scope, dataService, $location,$window){
                        $scope.check_login=function($event,userID,passwd)
                       {
                         dataService.login(userID,passwd).then
                        (

                        function (response){

                         $scope.loginCount = response.rowCount + 'account Record';
                         $scope.loginConfirm = response.data;

                         console.log(response.data);
                         },
                        function (err) {

                         $scope.status = 'unable to connect to data' + err;

                        });
                        // $scope.reloadRoute = function () {
                        // $location.path('/#');
                        // $window.location.reload()


                        // }//end of reload route fnction
                       }//end of function check_login 


                }

            ]

Services.js

代码语言:javascript
复制
this.login = function (userID, passwd) {
                  var defer = $q.defer(),

                    data = {
                      username: userID,
                      password: passwd
                      };

                    $http.post(urlBase, {
                              params: data,
                              headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                              cache: true
                      })
                      . // notice the dot to start the chain to success()
                    success(function (response) {
                    defer.resolve({
                    data: response.login.Result, // create data property with value from response
                    rowCount: response.login.RowCount // create rowCount property with value from response
                    });
                  })
              . // another dot to chain to error()
            error(function (err) {
              defer.reject(err);
            });
            // the call to getCourses returns this promise which is fulfilled 
            // by the .get method .success or .failure
            return defer.promise;
          };

index.php

代码语言:javascript
复制
if (isset($_POST['username']) && isset($_POST['password'])) {
            $useremail = $_POST['username'];
            $password  = $_POST['password'];
            $service   = new FilmsService();
            $result    = $service->login($useremail, $password);
            echo $result;
        } else {
            echo "Cant Find The Data";
        }

目前,我得到了3个文件名:控制器 service.js index.php,service.js是u将数据传递给php端,但当我尝试在php端获取用户名密码E 212时,将是error.Cant get E 113用户名E 214和E 115密码E 216。

如何解决这个问题?是我的代码错误吗?

EN

回答 1

Stack Overflow用户

发布于 2016-03-18 16:52:28

用这个代替您的$http.post:

代码语言:javascript
复制
$http({
 method: 'POST',
 url: urlBase,
 headers: {
   'Content-Type': 'application/x-www-form-urlencoded'
 },
 data: data
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36089654

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档