I have a URL like this http://localhost/phpdemo/edit_data.php?edt_id=1
. Here I need the query string value which is 1
. By using Angular.js, I am getting the following output in browser's console.
id is : Object {}
My code is given below.
update.js:
var app=angular.module("edit_data", []);
app.controller("updateController",function($scope,$http,$location){
$scope.errors = [];
$scope.msgs = [];
var id=$location.search();
console.log("id is :",id);
$http.get('js/edit.php',{"user_id":$location.hash()}).success(function(response){
console.log('response',response);
});
$scope.update_data=function(){
$http.post('js/update.php',{"first_name":$scope.first_name,"last_name":$scope.last_name,"city":$scope.city}
).success(function(data, status, headers, config){
if(data.msg!=''){
$scope.msgs.push(data.msg);
}else{
$scope.errors.push(data.error);
}
}).error(function(data, status) { // called asynchronously if an error occurs
// or server returns response with an error status.
$scope.errors.push(status);
});
}
});
Please help me to resolve this issue.