If you're not concerned about the parameters of the query string being 
human readable then you can base64 encode the object using JavaScript's 
native btoa function, and then decode it the other end. For example:

Encoding:

    $location.search('a', btoa(angular.toJson(obj)));

Decoding:

    var search = $location.search();
    if (search.a) {
        var obj = angular.fromJson(atob(search.a));
    }




On Tuesday, 23 April 2013 11:38:29 UTC+1, Anirvan Mandal wrote:
>
> I have gone through the angularjs $location guide 
> <http://docs.angularjs.org/guide/dev_guide.services.$location> on how to 
> use $location.search({a: 'b'}) for setting the query parameters for the 
> current window location. 
> It works fine for single level parameters. 
>
> For Example $location.search({'bob': 'marley'}) == 
> some/base/url/?bob=marley
>
>
> The problem arises when I want to make a multi-level query parameters.
>
> For example $location.search({'musician': {'bob': 'marley'}}) == 
> some/base/url/?musician=%5Bobject%20Object%5D
>
>
> Whereas I would want some thing like 
> some/base/url/?musician%5Bbob%5D=marley
>
> Is there something that I am doing wrong or is it an angular js bug?
>
> If it is a bug then is there any other way to generate a multi level query 
> parameters which has nested array and hashes?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to