Difference between passing parameters in URL vs as a param object in angular js

127 views Asked by At

I am trying to understand the difference between two rest calls .

One with params object like below -

$http({
        url : 'rest/getAllData',
        method : "GET",
        params : {
            A: $scope.A,
            B: $scope.B
}

And second in URL -

 var win = window.open('rest/getAllData/?A=' + $scope.A+ '&B=' + $scope.B );

Problem is in my first rest call , the date time which I getting from angular calendar is in the format

1989-12-31T00:00:00.000Z

But on second call I am getting format as

Sun Apr 30 2017 00:00:00 GMT 0530 (India Standard Time).

Can anyone please explain why is this happening ? Also , is there a way to use params object in windows.open() itself ?

Update -

Understood that URL by default invokes toString() method . That is the reason for the format change . Is there a way I can pass date object in windows.open() function??

Answer-

using toISOString() solved my problem . Thanks Claies

0

There are 0 answers