Sunday, 15 August 2010

javascript - How to parse default query parameter in angular -



javascript - How to parse default query parameter in angular -

i'd read values of url query parameters using angularjs. i'm accessing html next url:

http://demo.com/demo/demo.html?param1=125&param=4

the controller:

class="snippet-code-js lang-js prettyprint-override">app.controller( 'drawscontroller', ['$scope','$q','$location','$http', function($scope,$q,$location,$http){ var deferred = $q.defer(); $http({ url: "./api/api.php", method: "get", datatype: "json", params: { param1: $location.param1, param: $location.param } }) .success(function (data, status, headers, config) { }) .error(function (data, status, headers, config) { }); deferred.promise; }]);

var searchobject = $location.search(); var param1 = searchobject.param1; var param = searchobject.param;

javascript angularjs

No comments:

Post a Comment