php - Not getting query string value using angular.js -


i have url http://localhost/phpdemo/edit_data.php?edt_id=1. here need query string value 1. using angular.js, getting following output in browser's console.

id : object {} 

my code 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 :",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 error occurs                // or server returns response error status.               $scope.errors.push(status);         });     } }); 

please me resolve issue.

$location.search() return object of key-value pairs, same pairs query string. key has no value stored in object true. in case, object be:

var id=$location.search().edt_id; 

location service search little brief

search(search, [paramvalue]); method getter / setter.

return search part (as object) of current url when called without parameter.

change search part when called parameter , return $location.

// given url http://example.com/#/some/path?foo=bar&baz=xoxo var searchobject = $location.search(); // => {foo: 'bar', baz: 'xoxo'}  // set foo 'yipee' $location.search('foo', 'yipee'); // $location.search() => {foo: 'yipee', baz: 'xoxo'} 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -