如何通过angularjs中的web服务向android发送有效的json响应

时间:2015-04-10 09:52:11

标签: json angularjs web-services

我已经在android应用程序的angularjs中创建了webservice。 这是链接http://projects.developmentshowcase.com/fajr/#/login?vEmail=user@abc.com&vPassword=password

  

当我尝试将其解析为http://jsonlint.com/以验证json

enter image description here

  

我得到了这个结果

enter image description here

  

我想提供它们(android)只有JSON结果。喜欢beollow screeshot

enter image description here 这些是我的脚本:

的index.html

<!DOCTYPE html>
<html>
<head>
    <title>Fajr App</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/angular.min.js"></script>
    <script src="js/angular-route.min.js"></script>
    <script src="js/angular-file-upload.js"></script>
    <script src="app/app.js"></script>
    <script src="app/data.js"></script>
    <script src="app/directives.js"></script>
</head>
<body >
    <div ng-app="myApp">
        <div data-ng-view="" id="ng-view" class="slide-animation"></div>
    </div>
</body>
</html>

app.js

var app = angular.module('myApp', ['ngRoute', 'angularFileUpload']);

app.config(['$routeProvider',
function ($routeProvider) {
    $routeProvider
            .when('/login', {
                title: 'login',
                templateUrl: 'partials/dashboard.html',
                controller: 'authCtrl'
            })
            .when('/fblogin', {
                title: 'login',
                templateUrl: 'partials/dashboard.html',
                controller: 'authCtrl'
            })
            ;
}])
    .run(function ($rootScope, $location, Data, $templateCache) {
        $rootScope.$on("$viewContentLoaded", function () {
            $templateCache.removeAll();
        });
    });


app.controller('authCtrl', ['$scope', 'Data', '$location', '$window', function ($scope, Data, $location, $window) {
    if ($location.search().vFacebookID) {
        Data.get('authentication.php?vEmail=' + $location.search().vEmail + '&vFacebookID=' + $location.search().vFacebookID + '&vDeviceType=' + $location.search().vDeviceType + '&vDeviceToken=' + $location.search().vDeviceToken).then(function (results) {
            $scope.result = results;
        });
    } else {
        Data.get('authentication.php?vEmail=' + $location.search().vEmail + '&vPassword=' + $location.search().vPassword).then(function (results) {
            $scope.result = results;
        });
    }
}]);

dashboard.html

{{result}}

0 个答案:

没有答案