cordova - AngularJS JSON Parsing issue...below is the response i dont know how to parse data -
below response
{ "messages": { "httpcode": 200, "message": "signed in successfully" } }
below code controller, want make loop if httpcode == 200 , want assign value variable
var res = $http.post('http://webservices.it.com/webservices/services/customerdetail/login', data); res.success(function(data, status, headers, config) { console.log("check", json.stringify(data)); $scope.status = status; console.log("data", $scope.data); console.log("b1222", $scope.messages); console.log("status", $scope.status); console.log("status", $scope.headers); console.log("status", $scope.config); alert(" message: " + json.stringify({ data: data })); }); res.error(function(data, status, headers, config) { $scope.error = data; console.log("status", $scope.error); alert("failure message: " + json.stringify({ data: data })); }); console.log('log', data); console.log('sign-in', $scope.user.username); console.log('sign-in', $scope.user.password); $location.path("/track imei"); } };
$http.get("your url") .success(function(response) { $scope.messages = response.messages; $scope.httpcode=$scope.messages.httpcode; $scope.message=$scope.messages.message; });
in design:
<div> <span><h2>{{httpcode}}</h2></span><br> <span><h2>{{message}}</h2></span><br> </div>
Comments
Post a Comment