mardi 5 juillet 2016

Ember js - how to access a query param which is an array

I am working on an Ember app (version 1.11) where I need to read query params,one of which is an array, but I am not able to.

A form is being submitted and query params are being sent via that which triggers my ember app url (having those query params).

Route:

var route = Ember.Route.extend({
        queryParams: {
            price: { refreshModel: true, replace: false },
            list: { refreshModel: true, replace: false }
        },
});

Controller:

var controller = Ember.Controller.extend({
        queryParams: [
            { price: 'priceTag' },
            { list: 'listArray' }
        ],
        price: null,
        list: null
    });
});

URL:

https://localhost/home?list=26%2C23%2C90&price=300

The values in list are stored in an input's value together - 26,23,90.

When to try to access the params in my service.js, it shows as NAN. But when I just have only one value such as 26, it works.

So, how can i access these params more like an array in my ember code. I think would need to decode as well to remove the %2C in between.




Aucun commentaire:

Enregistrer un commentaire